且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

.NET Framework编译C#脚本的错误?

更新时间:2023-02-11 13:23:30

那是不是.Net Framework的错误。

完全相同的事情发生在没有.Net Framework的Javascript中。


scriptString构建一个JavaScript客户端函数。分离结束标记可以防止Javascript被动态解释:
scriptString + ="< / script&quot ;;
scriptString + =">&quot ;;


如果在呈现页面时执行JavaScript,

而不是点击按钮时,你会遇到更糟糕的问题。 />


Juan T. Llibre,asp.net MVP

aspnetfaq.com: http://www.aspnetfaq.com/

asp.net faq: http://asp.net.do/faq/

foros de asp.net,en espa ?ol: http://asp.net.do/foros/

===================================

&quot ;理查德&QUOT; &LT;日********************** @ USComputerGurus.com&GT;在消息中写道

新闻:11 ********************** @ j33g2000cwa.googlegr oups.com ...大家好,
但是如果在追加
结束">"后,删除最后一个scriptString行。在上一行中,编译器在浏览器(Firefox 5.0)的最后一行标记消息:

编译器错误消息:CS1010:常量换行符
>在Visual Web Developer 2005 Expr。
Ed。,版本8.0.50727.42中立即标记相同的行,其中Newline in constant。 VWD还抱怨最后的< / script>没有匹配的开始标记。

这是一个通用错误吗? :-),或者都是由.NET
C#编译器中的错误引起的?

一个想法?这太微不足道了吗?

TIA,
理查德

========= ASPX开始======== ===
<%@ Page Language =" c#" %>
< script runat =" server">

public void Page_Load(Object sender,EventArgs e){

//形成脚本这是在客户端注册的。
String scriptString ="&quot ;;

scriptString + ="< script language = JavaScript> &quot ;;
scriptString + =" function DoClick()&quot ;;
scriptString + =" {&quot ;;
scriptString + =" myForm.show.value =''Msg来自
Btn.DoClick()''&quot ;;
scriptString + ="}&quot ;;
scriptString + ="< / script&quot ;;
scriptString + =">&quot ;;

if(!this.IsClientScriptBlockRegistered(" clientScript"))
this.RegisterClientScriptBlock(" clientScript", scriptString);

< / script>
< html>
< head>
<! - 上面的指令不是orig 。 - 由WebMatrix&添加WebDev
2005 EE - >
< / head>
< body topmargin =" 20">
< form id =" myForm" runat =" server">
< input id =" show" style =" WIDTH:200px"类型= QUOT;文本&QUOT; />
< input onclick =" DoClick()"类型= QUOT按钮&QUOT;值= QUOT; ClickMe&QUOT; />
< / form>
< / body>
< / html>
========== ASPX结束==== =======



嗨Juan,


非常感谢你回答我的问题。


我对此进行了进一步检查。我发现了一些东西。


1.重申一下:当脚本的声明分开时

"< / script"和>在Test.aspx中:

- 文件在Web Matrix的设计视图中显示正常;

- 在Web Matrix的关联Web服务器中正常运行;最终

- 在Firefox中显示一个表单正常工作。


2.但是,如果我双击Test.aspx,Visual Web Developer会来

up和barfs立刻。除其他外,它标记行:

scriptString + ="< / script&quot ;;

投诉:

无法切换views:验证(Internet Explorer 6):字符

''"''在结束标记内无效。


3.努力了解你的评估完全相同的事情

发生在没有.Net Framework参与的Javascript中,我的b $ b组成了下面显示的HTML文件,在Firefox和IE中运行良好

(关闭脚本标签正常写入。)


如果你有时间,可以进一步了解我的经历和

进一步评估。


再次,感谢您花时间考虑我的困惑。


您真的,

Richard


=============== Test.html =============

< html>

< head>

< script language = JavaScript>

函数DoC舔()

{

myForm.show.value =''来自Btn.DoClick的消息()''

}

< / script>

< / head>

< body topmargin =" 20">

&lt ; form id =" myForm">

< input id =" show" style =" WIDTH:200px"类型= QUOT;文本&QUOT; />

< input onclick =" DoClick()"类型= QUOT按钮&QUOT;值= QUOT; ClickMe&QUOT; />

< / form>

< / body>

< / html>

=============== Test.html =============


Juan T. Llibre写道:
这不是.Net Framework的错误。
在没有.Net Framework的情况下Javascript也会发生同样的事情。

scriptString构建一个JavaScript客户端函数。

分隔结束标记可以防止Javascript被解释:
scriptString + ="< / script&quot ;;
scriptString + =">&quot ;;



如果在呈现页面时执行JavaScript,而不是点击按钮时,你就是'问题更糟糕。




Juan T. Llibre,asp.net MVP
aspnetfaq.com: http://www.aspnetfaq.com/
asp.net faq: http://asp.net.do/faq/
foros de asp.net,en espa?ol: http://asp.net.do/foros/
========= ==========================
理查德 &LT;日********************** @ USComputerGurus.com&GT;在消息中写道
新闻:11 ********************** @ j33g2000cwa.googlegr oups.com ...

大家好,

下面的ASPX文件在WinXP / SP2下的ASP .NET WebMatrix 0.6中运行良好,具有IIS 5.1和.NET Framework 1.0,1.1和2.0。

结束">"后删除了最后一个scriptString行。在上一行中,编译器在浏览器(Firefox 5.0)的最后一行标记消息:

编译器错误消息:CS1010:常量换行符
>在Visual Web Developer 2005 Expr。
Ed。,版本8.0.50727.42中立即标记相同的行,其中Newline in constant。 VWD还抱怨最后的< / script>没有匹配的开始标记。

这是一个通用错误吗? :-),或者都是由.NET
C#编译器中的错误引起的?

一个想法?这太微不足道了吗?

TIA,
理查德

========= ASPX开始======== ===
<%@ Page Language =" c#" %>
< script runat =" server">

public void Page_Load(Object sender,EventArgs e){

//形成脚本这是在客户端注册的。
String scriptString ="&quot ;;

scriptString + ="< script language = JavaScript> &quot ;;
scriptString + =" function DoClick()&quot ;;
scriptString + =" {&quot ;;
scriptString + =" myForm.show.value =''Msg来自
Btn.DoClick()''&quot ;;
scriptString + ="}&quot ;;
scriptString + ="< / script&quot ;;
scriptString + =">&quot ;;

if(!this.IsClientScriptBlockRegistered(" clientScript"))
this.RegisterClientScriptBlock(" clientScript", scriptString);

< / script>
< html>
< head>
<! - 上面的指令不是orig 。 - 由WebMatrix&添加WebDev
2005 EE - >
< / head>
< body topmargin =" 20">
< form id =" myForm" runat =" server">
< input id =" show" style =" WIDTH:200px"类型= QUOT;文本&QUOT; />
< input onclick =" DoClick()"类型= QUOT按钮&QUOT;值= QUOT; ClickMe&QUOT; />
< / form>
< / body>
< / html>
========== ASPX结束==== =======




您需要了解在文件中编写Javascript块之间的区别

只会被渲染和显示,并在一个文件中编写一个Javascript块,就像ASP和ASP.NET中的
一样,需要进行解释,编译和显示。 br />


Juan T. Llibre,asp.net MVP

aspnetfaq.com: http://www.aspnetfaq.com/

asp.net faq: http://asp.net.do/faq/

foros de asp.net,en espa?ol: http://asp.net.do/foros/ b $ b ===================================

&QUOT;理查德&QUOT; &LT;日********************** @ USComputerGurus.com&GT;在留言中写道

news:11 ********************** @ g10g2000cwb.googlegr oups.com ......

嗨Juan,


非常感谢您回答我的问题。


我对此进行了进一步检查。我发现了一些东西。


1.重申一下:当脚本的声明分开时

"< / script"和>在Test.aspx中:

- 文件在Web Matrix的设计视图中显示正常;

- 在Web Matrix的关联Web服务器中正常运行;最终

- 在Firefox中显示一个表单正常工作。


2.但是,如果我双击Test.aspx,Visual Web Developer会来

up和barfs立刻。除其他外,它标记行:

scriptString + ="< / script&quot ;;

投诉:

无法切换views:验证(Internet Explorer 6):字符

''"''在结束标记内无效。


3.努力了解你的评估完全相同的事情

发生在没有.Net Framework参与的Javascript中,我的b $ b组成了下面显示的HTML文件,在Firefox和IE中运行良好

(关闭脚本标签正常写入。)


如果你有时间,可以进一步了解我的经历和

进一步评估。


再次,感谢您花时间考虑我的困惑。


您真的,

Richard


=============== Test.html =============

< html>

< head>

< script language = JavaScript>

函数DoC舔()

{

myForm.show.value =''来自Btn.DoClick的消息()''

}

< / script>

< / head>

< body topmargin =" 20">

&lt ; form id =" myForm">

< input id =" show" style =" WIDTH:200px"类型= QUOT;文本&QUOT; />

< input onclick =" DoClick()"类型= QUOT按钮&QUOT;值= QUOT; ClickMe&QUOT; />

< / form>

< / body>

< / html>

=============== Test.html =============

Juan T. Llibre写道:这不是.Net Framework的错误。
在没有.Net Framework的情况下Javascript也会发生同样的事情。

scriptString构建了一个JavaScript客户端函数。

分隔结束标记可以防止Javascript被动态解释:
scriptString + ="< / script&quot ;;
scriptString + =">&quot ;;



如果在呈现页面时执行JavaScript,而不是点击按钮时,你会有更糟糕的问题。

Juan T. Llibre,asp.net MVP
aspnetfaq.com: http://www.aspnetfaq.com/
asp.net faq: http://asp.net.do/faq/
foros de asp.net,en espa?ol: http://asp.net.do/foros/
============== =====================
理查德 &LT;日********************** @ USComputerGurus.com&GT;在消息中写道
新闻:11 ********************** @ j33g2000cwa.googlegr oups.com ...

大家好,

下面的ASPX文件在WinXP / SP2下的ASP .NET WebMatrix 0.6中运行良好,具有IIS 5.1和.NET Framework 1.0,1.1和2.0。

结束">"后删除了最后一个scriptString行。在上一行中,编译器在浏览器(Firefox 5.0)的最后一行标记消息:

编译器错误消息:CS1010:常量换行符
>在Visual Web Developer 2005 Expr。
Ed。,版本8.0.50727.42中立即标记相同的行,其中Newline in constant。 VWD还抱怨最后的< / script>没有匹配的开始标记。

这是一个通用错误吗? :-),或者都是由.NET
C#编译器中的错误引起的?

一个想法?这太微不足道了吗?

TIA,
理查德

========= ASPX开始======== ===
<%@ Page Language =" c#" %>
< script runat =" server">

public void Page_Load(Object sender,EventArgs e){

//形成脚本这是在客户端注册的。
String scriptString ="&quot ;;

scriptString + ="< script language = JavaScript> &quot ;;
scriptString + =" function DoClick()&quot ;;
scriptString + =" {&quot ;;
scriptString + =" myForm.show.value =''Msg来自
Btn.DoClick()''&quot ;;
scriptString + ="}&quot ;;
scriptString + ="< / script&quot ;;
scriptString + =">&quot ;;

if(!this.IsClientScriptBlockRegistered(" clientScript"))
this.RegisterClientScriptBlock(" clientScript", scriptString);

< / script>
< html>
< head>
<! - 上面的指令不是orig 。 - 由WebMatrix&添加WebDev
2005 EE - >
< / head>
< body topmargin =" 20">
< form id =" myForm" runat =" server">
< input id =" show" style =" WIDTH:200px"类型= QUOT;文本&QUOT; />
< input onclick =" DoClick()"类型= QUOT按钮&QUOT;值= QUOT; ClickMe&QUOT; />
< / form>
< / body>
< / html>
========== ASPX结束==== =======



Hi All,

The ASPX file below runs fine in ASP .NET WebMatrix 0.6 under WinXP/SP2
with IIS 5.1 and .NET Framework 1.0, 1.1 and 2.0.

But if the last scriptString line is eliminated after appending the
closing ">" to the preceding line, the compiler flags that last line in
the browser (Firefox 5.0) with the message:

Compiler Error Message: CS1010: Newline in constant

The same line is flagged immediately in Visual Web Developer 2005 Expr.
Ed., version 8.0.50727.42, with "Newline in constant". VWD also
complains that the final </script> had no matching start tag.

Is this a "universal bug" :-), or are both caused by a bug in the .NET
C# compiler?

An ideas? Is this too trivial to worry about?

TIA,
Richard

========= ASPX start ===========
<%@ Page Language="c#" %>
<script runat="server">

public void Page_Load(Object sender, EventArgs e) {

// Form the script that is to be registered at client side.
String scriptString = "";

scriptString += "<script language=JavaScript> ";
scriptString += "function DoClick()";
scriptString += "{";
scriptString += " myForm.show.value=''Msg from
Btn.DoClick()''";
scriptString += "}";
scriptString += "</script";
scriptString += ">";

if( !this.IsClientScriptBlockRegistered("clientScript" ) )
this.RegisterClientScriptBlock("clientScript", scriptString);
}

</script>
<html>
<head>
<!-- Directive above not orig. -- added by both WebMatrix & WebDev
2005 EE -->
</head>
<body topmargin="20">
<form id="myForm" runat="server">
<input id="show" style="WIDTH: 200px" type="text" />
<input onclick="DoClick()" type="button" value="ClickMe" />
</form>
</body>
</html>
========== ASPX end ===========

That is not a .Net Framework bug.
The exact same thing happens in Javascript without the .Net Framework being involved.

scriptString builds a JavaScript client function.

Separating the closing tag prevents the Javascript from being interpreted on the fly:
scriptString += "</script";
scriptString += ">";
If the JavaScript executed when the page is rendered,
instead of when the button''s clicked, you''d have worse problems.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
"Richard" <Ri**********************@USComputerGurus.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com... Hi All,

The ASPX file below runs fine in ASP .NET WebMatrix 0.6 under WinXP/SP2
with IIS 5.1 and .NET Framework 1.0, 1.1 and 2.0.

But if the last scriptString line is eliminated after appending the
closing ">" to the preceding line, the compiler flags that last line in
the browser (Firefox 5.0) with the message:

Compiler Error Message: CS1010: Newline in constant

The same line is flagged immediately in Visual Web Developer 2005 Expr.
Ed., version 8.0.50727.42, with "Newline in constant". VWD also
complains that the final </script> had no matching start tag.

Is this a "universal bug" :-), or are both caused by a bug in the .NET
C# compiler?

An ideas? Is this too trivial to worry about?

TIA,
Richard

========= ASPX start ===========
<%@ Page Language="c#" %>
<script runat="server">

public void Page_Load(Object sender, EventArgs e) {

// Form the script that is to be registered at client side.
String scriptString = "";

scriptString += "<script language=JavaScript> ";
scriptString += "function DoClick()";
scriptString += "{";
scriptString += " myForm.show.value=''Msg from
Btn.DoClick()''";
scriptString += "}";
scriptString += "</script";
scriptString += ">";

if( !this.IsClientScriptBlockRegistered("clientScript" ) )
this.RegisterClientScriptBlock("clientScript", scriptString);
}

</script>
<html>
<head>
<!-- Directive above not orig. -- added by both WebMatrix & WebDev
2005 EE -->
</head>
<body topmargin="20">
<form id="myForm" runat="server">
<input id="show" style="WIDTH: 200px" type="text" />
<input onclick="DoClick()" type="button" value="ClickMe" />
</form>
</body>
</html>
========== ASPX end ===========



Hi Juan,

Thank you very much for responding to my question.

I checked further on this. I''ve discovered a few things.

1. Just to reiterate: When the declartion of of the script separates
"</script" and ">" in Test.aspx:
-- the file displays fine in Web Matrix''s Design view;
-- runs fine in Web Matrix''s associated Web Server; and ultimately
-- displays a form in Firefox which works fine.

2. However, if I double-click Test.aspx, Visual Web Developer comes
up and barfs immediately. Among other things, it flags the line:
scriptString += "</script";
with the complaint:
Cannot switch views: Validation (Internet Explorer 6): Character
''"'' is not valid inside closing tags.

3. In an effort to understand your assessment "The exact same thing
happens in Javascript without the .Net Framework being involved", I
composed the HTML file shown below which runs fine in Firefox and IE
(with the closing script tag written normally.)

If you have time, could you take a further look at my experiences and
assess it further.

Again, thanks for taking the time to consider my confusion.

Yours truly,
Richard

=============== Test.html =============
<html>
<head>
<script language=JavaScript>
function DoClick()
{
myForm.show.value=''Msg from Btn.DoClick()''
}
</script>
</head>
<body topmargin="20">
<form id="myForm">
<input id="show" style="WIDTH: 200px" type="text" />
<input onclick="DoClick()" type="button" value="ClickMe" />
</form>
</body>
</html>
=============== Test.html =============


Juan T. Llibre wrote:
That is not a .Net Framework bug.
The exact same thing happens in Javascript without the .Net Framework being involved.

scriptString builds a JavaScript client function.

Separating the closing tag prevents the Javascript from being interpretedon the fly:
scriptString += "</script";
scriptString += ">";



If the JavaScript executed when the page is rendered,
instead of when the button''s clicked, you''d have worse problems.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
"Richard" <Ri**********************@USComputerGurus.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...

Hi All,

The ASPX file below runs fine in ASP .NET WebMatrix 0.6 under WinXP/SP2
with IIS 5.1 and .NET Framework 1.0, 1.1 and 2.0.

But if the last scriptString line is eliminated after appending the
closing ">" to the preceding line, the compiler flags that last line in
the browser (Firefox 5.0) with the message:

Compiler Error Message: CS1010: Newline in constant

The same line is flagged immediately in Visual Web Developer 2005 Expr.
Ed., version 8.0.50727.42, with "Newline in constant". VWD also
complains that the final </script> had no matching start tag.

Is this a "universal bug" :-), or are both caused by a bug in the .NET
C# compiler?

An ideas? Is this too trivial to worry about?

TIA,
Richard

========= ASPX start ===========
<%@ Page Language="c#" %>
<script runat="server">

public void Page_Load(Object sender, EventArgs e) {

// Form the script that is to be registered at client side.
String scriptString = "";

scriptString += "<script language=JavaScript> ";
scriptString += "function DoClick()";
scriptString += "{";
scriptString += " myForm.show.value=''Msg from
Btn.DoClick()''";
scriptString += "}";
scriptString += "</script";
scriptString += ">";

if( !this.IsClientScriptBlockRegistered("clientScript" ) )
this.RegisterClientScriptBlock("clientScript", scriptString);
}

</script>
<html>
<head>
<!-- Directive above not orig. -- added by both WebMatrix & WebDev
2005 EE -->
</head>
<body topmargin="20">
<form id="myForm" runat="server">
<input id="show" style="WIDTH: 200px" type="text" />
<input onclick="DoClick()" type="button" value="ClickMe" />
</form>
</body>
</html>
========== ASPX end ===========




You need to understand the difference between writing a Javascript block in a file
which will only be rendered and displayed, and writing a Javascript block in a file,
like in ASP and ASP.NET, which needs to be interpreted, compiled and displayed.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
"Richard" <Ri**********************@USComputerGurus.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hi Juan,

Thank you very much for responding to my question.

I checked further on this. I''ve discovered a few things.

1. Just to reiterate: When the declartion of of the script separates
"</script" and ">" in Test.aspx:
-- the file displays fine in Web Matrix''s Design view;
-- runs fine in Web Matrix''s associated Web Server; and ultimately
-- displays a form in Firefox which works fine.

2. However, if I double-click Test.aspx, Visual Web Developer comes
up and barfs immediately. Among other things, it flags the line:
scriptString += "</script";
with the complaint:
Cannot switch views: Validation (Internet Explorer 6): Character
''"'' is not valid inside closing tags.

3. In an effort to understand your assessment "The exact same thing
happens in Javascript without the .Net Framework being involved", I
composed the HTML file shown below which runs fine in Firefox and IE
(with the closing script tag written normally.)

If you have time, could you take a further look at my experiences and
assess it further.

Again, thanks for taking the time to consider my confusion.

Yours truly,
Richard

=============== Test.html =============
<html>
<head>
<script language=JavaScript>
function DoClick()
{
myForm.show.value=''Msg from Btn.DoClick()''
}
</script>
</head>
<body topmargin="20">
<form id="myForm">
<input id="show" style="WIDTH: 200px" type="text" />
<input onclick="DoClick()" type="button" value="ClickMe" />
</form>
</body>
</html>
=============== Test.html =============

Juan T. Llibre wrote:
That is not a .Net Framework bug.
The exact same thing happens in Javascript without the .Net Framework being involved.

scriptString builds a JavaScript client function.

Separating the closing tag prevents the Javascript from being interpreted on the fly:
scriptString += "</script";
scriptString += ">";



If the JavaScript executed when the page is rendered,
instead of when the button''s clicked, you''d have worse problems.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
"Richard" <Ri**********************@USComputerGurus.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...

Hi All,

The ASPX file below runs fine in ASP .NET WebMatrix 0.6 under WinXP/SP2
with IIS 5.1 and .NET Framework 1.0, 1.1 and 2.0.

But if the last scriptString line is eliminated after appending the
closing ">" to the preceding line, the compiler flags that last line in
the browser (Firefox 5.0) with the message:

Compiler Error Message: CS1010: Newline in constant

The same line is flagged immediately in Visual Web Developer 2005 Expr.
Ed., version 8.0.50727.42, with "Newline in constant". VWD also
complains that the final </script> had no matching start tag.

Is this a "universal bug" :-), or are both caused by a bug in the .NET
C# compiler?

An ideas? Is this too trivial to worry about?

TIA,
Richard

========= ASPX start ===========
<%@ Page Language="c#" %>
<script runat="server">

public void Page_Load(Object sender, EventArgs e) {

// Form the script that is to be registered at client side.
String scriptString = "";

scriptString += "<script language=JavaScript> ";
scriptString += "function DoClick()";
scriptString += "{";
scriptString += " myForm.show.value=''Msg from
Btn.DoClick()''";
scriptString += "}";
scriptString += "</script";
scriptString += ">";

if( !this.IsClientScriptBlockRegistered("clientScript" ) )
this.RegisterClientScriptBlock("clientScript", scriptString);
}

</script>
<html>
<head>
<!-- Directive above not orig. -- added by both WebMatrix & WebDev
2005 EE -->
</head>
<body topmargin="20">
<form id="myForm" runat="server">
<input id="show" style="WIDTH: 200px" type="text" />
<input onclick="DoClick()" type="button" value="ClickMe" />
</form>
</body>
</html>
========== ASPX end ===========