|
-
Feb 15th, 2003, 10:45 PM
#1
Thread Starter
PowerPoster
Saving a multiline textbox into db with html formatting?
I am creating a user forum, much like these ones. I am having a little problem though.
When you type in your reply or new post, the newlines get lost when saving the text to the db (SQL Server 2000, text field). I want to be able to insert <br> tags for the newlines, but don't know how to go about it. Any suggestions?
Example of what I mean:
The empty lines between the paragraphs in this post, they don't show up when I save them to the db in my forums.
-
Feb 16th, 2003, 07:22 AM
#2
Hyperactive Member
VB Code:
Txt.Text = Replace(Txt.Text,vbCrLF,"<br>")
Then input Txt.Text into your Database as normal
-
Feb 16th, 2003, 12:33 PM
#3
Thread Starter
PowerPoster
That is great, but I am doing this in C#. Would I be looking for the \r\n in that case? I will give it a try.
-
Feb 16th, 2003, 03:55 PM
#4
Thread Starter
PowerPoster
Ok, this is very annoying. Here is the code I am using:
string message = MessageText.Text; // That is a multiline textbox.
message.Replace(Environment.NewLine, "<br>");
It doesn't do anything. It is like when the text is being posted back to the server, all newlines are taken out. Anyone know what is going on?
-
Feb 16th, 2003, 10:23 PM
#5
Thread Starter
PowerPoster
Boy, I feel silly. I wasn't assigning the result of the replace back to a string variable. It is working now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|