Response.write javascript causing newline in Constant
I cant figure this out, here is my code:
Response.Write("<html><script type='text/javascript'></script>开发者_StackOverflow</body></html>");
Response.End();
Which is causing this error:
Compiler Error Message: CS1010: Newline in constant
I'm not sure how to get around it. This is c# and asp.net 2.0.
Any ideas?
It seems to be happening around the closing tag - when I pull that out - it works fine. Hmm
Ok I fixed it, it was the closing tag. Was causing an error.
Here is the fix:
Response.Write("<script>\n");
Response.Write("</script" + ">");
The code shown is ok, show surrounding code. You simple forgot to close a string, or forgot to escape a literal quote, or a backslash, etc.
"Newline in constant" probably means:
You opened up a string
"
quote marker somewhere and forgots to close it.
The C# interpreter can gets confuse about which quote is actually opening and which is actually closing sometimes.
Look at the last few lines you've edited and check thoroughly for any syntax errors.
Just a guess, but perhaps you copied the code from somewhere that had just a carriage return without a linefeed or vice versa? Try copying the code back from Stack Overflow into your editor.
Also, are you sure that the error is coming from that line of code?
精彩评论