"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

6 Comments

  • &quot;This behavior is by design&quot;



    Why??



  • because the compiler things that the &lt;/SCRIPT&gt; in strAll is the closing tag for the &lt;script runat=&quot;server&quot;&gt;

    =========

    &lt;script runat=&quot;server&quot;&gt;

    private void Page_Load(object sender, System.EventArgs e)

    {

    string strValue = &quot;Test value&quot;;

    string strAll = &quot;&lt;SCRIPT lanquage='JScript'&gt;window.alert('&quot; + strValue + &quot;');&lt;/SCRIPT&gt;&quot;;

  • Writing in C#

    &lt;%#

    (&quot;&quot; + DataBinder.Eval(Container.DataItem,&quot;Expr1&quot;)==&quot;&quot;)? &quot;&lt;a href='T6003c.aspx?Expr5=Convert.ToString(DataBinder.Eval(Container.DataItem,&quot;Expr5&quot;)).Trim()'&gt;Add&lt;/a&gt;&quot;

    : &quot;&lt;a href='T6003c.aspx?'&gt;Edit&lt;/a&gt;&quot;

    %&gt;

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

  • NewLine in constant in VS.net 2005

  • Great work, thank you !!!!

Comments have been disabled for this content.