Microsoft KB Archive/827420

= PRB: &quot;CS1010: Newline in Constant&quot; Error Message When a String Contains a  Tag in the Inline Code =

Article ID: 827420

Article Last Modified on 5/17/2007

-

APPLIES TO


 * Microsoft ASP.NET 1.0
 * Microsoft ASP.NET 1.1

-





SYMPTOMS
When you try to browse an .aspx page with inline code that contains the  HTML tag, you may receive the following error message:

Server Error in '/ ' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1010: Newline in constant



WORKAROUND
To work around this problem, split the  tag in two or more strings such as &quot;<&quot; + &quot;/SCRIPT>&quot;, and then use inside script blocks as follows: private void Page_Load(object sender, System.EventArgs e)   { string strValue = &quot;Test value&quot;; string strAll = &quot;window.alert('&quot; + strValue + &quot;');<&quot;+&quot;/SCRIPT>&quot;; }



STATUS
This behavior is by design.



Steps to Reproduce the Problem
 Start Microsoft Visual Studio .NET. Use Microsoft Visual C# .NET to create a new ASP.NET Web Application project.

By default, WebForm1.aspx is created. In Design view, right-click WebForm1.aspx, and then click View HTML Source.  Replace the existing HTML code with the following code: <%@ Page%>  private void Page_Load(object sender, System.EventArgs e)   { string strValue = &quot;Test value&quot;; string strAll = &quot;<SCRIPT lanquage='JScript'>window.alert('&quot; + strValue + &quot;');</SCRIPT>&quot;; } <HTML> <HEAD> Test </HEAD> <body bgColor=#FFFFFF> <form id=&quot;test&quot; method=&quot;post&quot; runat=&quot;server&quot;> </HTML> </li> On the Debug menu, click Start to run the application.

You may receive the error message that is mentioned in the &quot;Symptoms&quot; section.</li></ol>

<div class="references_section">