Hi Fatima,
In the future you should post questions related to ASP.NET to the
microsoft.public.dotnet.framework.aspnet newsgroup.
ASP.NET isn't removing the spaces, the browser just isn't displaying them.
HTML whitespace is normally collapsed into a single space when rendered in a
browser.
Unfortunately, you can't just simply use the " " sequence to provides
spaces because ASP.NET will automatically encode it so it becomes,
" ", which will be displayed in the list box as text.
Try the following:
string space = HttpUtility.HtmlDecode(" ");
string item = " Four Spaces";
lstTextFromFile.Items.Add(item.Replace(" ", space));
--
Dave Sexton
<fa***********@gmail.comwrote in message
news:11*********************@80g2000cwy.googlegrou ps.com...
Hello,
I am creating a web page using c# and asp.net. I am trying to populate
a list box by reading text from a file.
The text in the file has leading spaces in order to show a hierarchy of
the items. I would like this formatting to show up in the listbox, but
it seems that strings are trimmed before adding them to the listbox.
Is there any way for the spaces in the strings I am adding to a list
box be kept? Is there another way of doing this or another control I
can use? Any help is appreciated.
If you need more clarification, please let me know.
Thanks,
Fatima