Can someone help me out please?I think I didn't explain myself well enough..
I have a textbox and when people type something out like this:
***************
This is my first line
This is my second line
***************
once I pull it out of a database, I want it to be displayed the same way... So it is displayed the way I type it out, like any of the posts on this board.
Can someone please help?
Assume that your text is stored in myString
If u want to convert it to html, use server.htmlencode(myString), it will convert sth. like "<" to "<". But it can't automatically generate <br>. So you have to use replace to do that
Finally, you can use
replace(server.htmlencode(myString), vbcrlf,"<br>")
BTW, basically, I will keep the original text in database, only encode them when output.
Why I do like that? Because when you want to update it, the html code will also be shown on the textbox for update, it confused the user much. So you'd better do the encoding in output, not do it when inserting it into database.
string temp = TextBox1.Text.ToString() + "<BR>";
Response.Write(temp);
that will do the trick
Thanks, got it working now...
Though there's a different way to encode it as html and stuff...
Thanks for the suggestion rgao906. It's a good idea
Lomex if you out three how do you do it?
when I used textbox.text i get a whole string like this:
Line 1. Line2.
I tried the above it doesn't insert the necessary <br
please help!
0 comments:
Post a Comment