Format text from db into HTML text

R

Rigga

Hi all,

Firstly, sorry for the simple question, as i'm sure i'm missing something
obvious.

I have a text field (varchar) I am reading from an SQL db, into a string
variable, in .NET

I am then assigning this string variable to an HTML control, either Label or
Textbox, depending on the edit situation.

The problem I am getting is that the text that is displayed on the web page
does not show the text formatting of the original text, i.e. carriage
returns etc.

So the q. how do I convert the text string in .NET to the html formatted
string to be displayed on the web page, and how do I then reverse that
process once the web user has edited the text?

And while I'm on the subject, is there an easy way to display RTF text in an
HTML control?

Thanks in Advance.
R.
 
G

Guest

Rigga, I don't think there's anything totally obvious--just do the
replacement yourself, e.g. string.replace \n (vbcrlf) with <br> and vice
versa.

Bill
 
R

Rigga

P.S. The textbox formatting is done by setting mode to Multiline obviously,
It's the Label text I am more interested in solving, so that as well as
retaining the formatting of the original text in terms of carriage returns
etc. the text can also be displayed in the visual style of the appropriate
web page.

Thanks.
R.
 
G

Guest

Hello
If the text that you bring form DB is not in HTML format you will need to
replace "carriage returns" with "<p>" or "<br>" using: lblTest=
replace(string, char(13), "<br>")
Regards
Saeid Kdaimati
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top