views:

413

answers:

5

Hey all,

I cant figure this out, here is my code:

Response.Write("<html><script type='text/javascript'></script></body></html>");
Response.End();

Which is causing this error: Compiler Error Message: CS1010: Newline in constant

Im not sure how to get around it. This is c# and asp.net 2.0.

Any ideas?

Jake

It seems to be happening around the closing tag - when I pull that out - it works fine. Hmm

A: 

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.

Aviad P.
A: 

Where is this code being called from?

Brian
A: 

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?

Eilon
A: 

"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.

chakrit
+1  A: 

Ok I fixed it, it was the closing tag. Was causing an error.

Here is the fix:

    Response.Write("<script>\n");
    Response.Write("</script" + ">");
jrutter