hey, when i type a string of multi-lined text into a text box then insert it into a feild in a table in my database, then when i get it out the new lines are missing :
String going into the database :
'line one
line two
line three'
Line coming out of the database
'line one line two line three'
I am using sql client and parameters, can anyone tell me why it does this and how to stop it from doing this? thanks Si
for editing a textbox, for displaying, in a label in a gridview row. for input its a textbox, it doesnt allow html (the insert parameter is Server.HtmlDecode(TextBox1.Text) stopping any invalid characters). Thanks in advance Si
The problem is you have carrage returns and line feeds in your text and HTML does not support those characters when you display in a label. You will either have to do a replace on the returns and line feeds and replace them with a <br/> tag for the read
only (HTML part) or use an HTML editor for your text boxes and allow Html to be saved.
Please mark the most helpful post(s) as Answer Blog | I need more space:DropBox Referral
Marked as answer by blink18jew on Apr 13, 2009 12:56 PM
blink18jew
Member
199 Points
648 Posts
keeping a strings formatting
Apr 13, 2009 01:20 AM|LINK
String going into the database :
'line one
line two
line three'
Line coming out of the database
'line one line two line three'
I am using sql client and parameters, can anyone tell me why it does this and how to stop it from doing this? thanks Si
whighfield
Star
11721 Points
1859 Posts
Re: keeping a strings formatting
Apr 13, 2009 03:28 AM|LINK
How are you displaying your text when it comes out of the database? In Html? A textbox?
Blog | I need more space:DropBox Referral
blink18jew
Member
199 Points
648 Posts
Re: keeping a strings formatting
Apr 13, 2009 03:38 AM|LINK
whighfield
Star
11721 Points
1859 Posts
Re: keeping a strings formatting
Apr 13, 2009 04:17 AM|LINK
The problem is you have carrage returns and line feeds in your text and HTML does not support those characters when you display in a label. You will either have to do a replace on the returns and line feeds and replace them with a <br/> tag for the read only (HTML part) or use an HTML editor for your text boxes and allow Html to be saved.
Blog | I need more space:DropBox Referral
blink18jew
Member
199 Points
648 Posts
Re: keeping a strings formatting
Apr 13, 2009 12:41 PM|LINK