Suresh Behera

The Microsoft .Net Junkies

News

Blogroll

Reading

"CS1010: Newline in Constant" Error Message

I got this error from asp.net application and here is the solution

Modify string as like

      string strValue = "Test value";
      string strAll = "<SCRIPT lanquage='JScript'>window.alert('" + strValue + "');<"+"/SCRIPT>";
More..
http://support.microsoft.com/default.aspx?scid=kb;EN-US;827420

Suresh Behera

Comments

Matt B said:

"This behavior is by design"

Why??
# October 11, 2005 9:01 AM

Raj Kaimal said:


because the compiler things that the </SCRIPT> in strAll is the closing tag for the <script runat="server">
=========
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
string strValue = "Test value";
string strAll = "<SCRIPT lanquage='JScript'>window.alert('" + strValue + "');</SCRIPT>";
# October 11, 2005 10:25 AM

m said:

Writing in C#
<%#
("" + DataBinder.Eval(Container.DataItem,"Expr1")=="")? "<a href='T6003c.aspx?Expr5=Convert.ToString(DataBinder.Eval(Container.DataItem,"Expr5")).Trim()'>Add</a>"
: "<a href='T6003c.aspx?'>Edit</a>"
%>
# October 20, 2005 11:12 PM

By design?! said:

That sounds like a serious flaw in IIS.  In any normal language environment the only plaintext characters in a delimited (i.e. quoted) string that need special treatment are the delimiters themselves (e.g.: the " character must be preceded by a \).

The fact that a magic sequence of characters within a quoted string - albeit one with significance in the context of HTML/SGML - but no significance in the current language context (C#) would be treated that way is atrocious.  IIS has no business looking inside a C# quoted string for anything.  Doing so breaks the C# implementation.

# June 8, 2007 8:47 AM

Ilayaraja said:

NewLine in constant in VS.net 2005

# September 20, 2007 8:25 AM

new line in constant said:

Pingback from  new line in constant

# July 9, 2008 2:51 PM

Anish said:

Error code

Line 30:

                   <asp:Image ID="Image1" runat="server" ImageUrl='<%# Handler.ashx?ID=" + Eval("ID") %>' />

# December 3, 2009 9:22 AM

Massimo Laboranti said:

Great work, thank you !!!!

# December 3, 2009 11:25 AM

Somi reddy said:

No single codes are required in alert.

# December 4, 2009 7:33 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)