473,473 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help with formatting

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

Nov 29 '06 #1
1 1611
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

Nov 30 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: dinoo | last post by:
I need your help I want to know what other options user have if he does not have Microsoft Word on his machine I would like to use word sort of application for formatting documents, these...
4
by: Wayne Aprato | last post by:
I have a simple database which was originally written in Access 97. When converted to Access 2000 file format it ran flawlessly in Access 2002. I've just tried to run it in Access 2003 and I am...
7
by: BBFrost | last post by:
I'm receiving decimal values from database queries and placing them on a report page. The users want to see the following .... Db Value Display Value 123.3400 123.34...
3
by: trint | last post by:
Ok, I have a textbox that I want to check as one types each charactor for Currency formatting, another one for Date formating. Any help is appreciated. Thanks, Trint
4
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown. Thanks
2
by: jodyblau | last post by:
I'm not certain that what I am trying to do is possible; in any event I haven't been able to figure it out. Here is what I am trying to do: I have one table that has a list of cases I'm working...
2
by: sgtted71 | last post by:
I have searched the Word Help and the Access Help, I have consulted the well used Access Bible that sits behind my desk, and to no avail...so now I consult the mighty brain trust that is...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
4
by: n.phelge | last post by:
I need to perform an XSLT to set the namespace on some XML and I need to preserve the original document line formatting to assist with error handling (so the line number from any schema validation...
8
by: babyangel43 | last post by:
Hello, I have a query set up in Access. I run it monthly, changing "date of test". I would like this query to be merged with a Word document so that the cover letter is created in Word, the fields...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.