|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
White spaces in DropDownList / Listbox / ...Hi all,
I want to add white spaces to format a DropDownList or another web control but when the control is rendered ASP.NET convert my " " to " " Without using to format the string, I cannot create create a combo like this USER1 | Alan Smith | 25/01/1981 USER2 | Brian Smith | 12/06/1983 ..... I can create a custom web control but I have to use ASP.NET native web controls.
Show quote
Hide quote
"Frederic H" <Freder***@discussions.microsoft.com> wrote in message Here is an example that was posted some time ago by someone else.news:3A2F8D49-D408-4727-8144-ACC552B2C3F8@microsoft.com... > Hi all, > > I want to add white spaces to format a DropDownList or another web control > but > when the control is rendered ASP.NET convert my " " to " " > Without using to format the string, I cannot create create a combo like > this > > USER1 | Alan Smith | 25/01/1981 > USER2 | Brian Smith | 12/06/1983 > .... > > I can create a custom web control but I have to use ASP.NET native web > controls. <%@ Page Language="VB" Debug="true" %> <script language=VB runat=server> Sub Page_Load(Sender As Object, E As EventArgs) Dim Padding As String Dim writer As New System.IO.StringWriter() Dim DecodedString As String Padding = " " Server.HtmlDecode(Padding, writer) Padding = writer.ToString() myDropDownList2.Items.Add(Padding & " MVP's") Padding = " " Server.HtmlDecode(Padding, writer) Padding = writer.ToString() myDropDownList2.Items.Add(Padding & " MVP's") myDropDownList2.Items.Add("MVP's" & Padding & "Do Their best") End Sub </script> <html> <head><title>Padding DropListBox</title></head> <body><form fred runat="server"><asp:dropdownlist id="MyDropDownList2" runat="server"/></form></body> </html> mike Thank you for this help!
(Server.HtmlDecode works only on ASP.NET : if you want to use it in another project (class library for example) use the System.Web.HttpUtility Class) Example : Dim writer As New System.IO.StringWriter Dim HttpUtils As New System.Web.HttpUtility HttpUtils.HtmlDecode(myRow("Description"), writer) myRow("Description") = writer.ToString writer.Close()
Problems with Re-Usable ASP.NET User Control Libraries
FtpWebRequest UploadFile Page_Error event issue Treeview tweak Accessing the values of textboxes/labels within a function How to insert a new record in detailsview when there are no record AutoEventWireUp Problem cannot access container data in templated control Webcontrol custom designer how to hide a root element in treeview when binding to sitemap?!? |
|||||||||||||||||||||||