Tuesday, March 13, 2012

so silly and newbie question

why that "\n" is not working? all data are being shown in the same line

Response.Write(yourName + "\n")

[its hard to find out answer on this search engine by writing "\n" or "change line"...]

tnxthe \n is a javascript formatting command...when you response.write something, you are just putting text on the screen, not javascript (unless you output script tags..etc..)

So, with what you have here, you could use something like:

Response.write(yourName & "<br>")

MajorCats
Its also an Escape in C#


string myString ="Robin Hood and Little John \n walking through the forest"
Response.Write(myString);

It gets fun when you use a registerClientScriptBlock to emit JavaScript and you need the JavaScript to contain a \n. Then in your string you end up with " \\n". Once to escape the \ so the \n can be rendered so the javascript can new line.

0 comments:

Post a Comment