Saturday, March 24, 2012

Text property values in Textboxes in ASP.NET

I have a website designed where users can enter a large amount of data into a mutlirow textbox. This can be stuff that has line breaks and such. The user can enter this information and it looks OK if I retrieve it from my SQL Database. When I retrieve it into a Windows Forms text box...it looks rather garbled. Is there a way to make them both look the same? I fear that if users muck with the values in my Windows Form support app, it will screw up the display for the web users.

Line breaks on an HTML page can only be achieved by using the <br /> tags, therefore a piece of text with paragraphs will just run together when it is pulled from the DB to the web page. What I do to fix this is I created a function called FormatHTML() that takes a string input and replaces all carriage returns with a "<br />" tag. The function does something like this...
TheString.Replace(CHR(10), "<br />")
You'll need to import Microsoft.VisualBasic to do that.


But the text from the HTML text boxes is not returning HTML tags in the text...actually it appears to be ASCII or something like that. That is what is baffling. To add to my story. I took a text box in Windows Forms on a record that was added from the web. Made complete changes in the multi line text box and saved it. When I re-opened it it looked like it got changed again and had little boxes where line feeds and carriage returns would be and munged it together into a single paragraph.

In SQL Server these text fields are bunched together and where carriage return and linefeeds would be it shows boxes. So if I create these text values in multiline text boxes on the web they look normal like this:
Benefits

This has the following values:

1. Data
2. Data 2
If I open up that value after it has been stored in the database it is all mashed together with boxes for carriage returns and linefeeds. If I edit it in a Windows Forms text box and make it look normal, and then submit that back to the database. The web looks like it does above but going back into the Windows Form text boxes returns it to the funky display. What is up with this??


Nobody??

0 comments:

Post a Comment