Reading out database cells with orinal formatting with dataset

liunx

Guest
Hi,

I am trying to find a way to have my asp.net app. show the content of a database formatted like it is present in my database (DB is used by a generic stand-alone app).
I notice that all new line formatting (the funny square) is ignored. How can I make sure that the data is shown in the same format at it is stored?I can think of 2 options off the top of my head. The squares are new line characters and newline characters are not rendered in HTML. So...

"abc
def"

would render like this "abcdef".

You can either wrap the text field with <pre></pre> tags or you can convert the newline characters to <br /> tags. Of course if you modify the text from the ASP app, you'll want to convert the text back to normal so that it still works well with your Windows app.

For example if your text is stored in the string "strText" you could do this:

strText = strText.Replace(VbCrLf,"<br />")
or
strText = "<pre>" & strText & "</pre>"


Hope that helps.Thanks for the input.
I have build a function to do the Textformatting in my codebehind.
However I get a very strange error: "The name 'vbcrlf' does not exist in the class or namespace 'project1.stdpage'

I have created the following code:
public string FormatText(string myText)
{StringBuilder sb = new StringBuilder(myText);
return (sb.Replace(vbcrlf, "<br>")).ToString();
}


The error is driving me insane :eek: since I cannot find any references on the web to what could be the reason for the error.Yes, I think that VbCrLf is specific to the VB language. Try System.Environment.NewLine.I got it working with "\r" for carriage return and "\n" for new line - simply replaced those with a <br>
 
Back
Top