简单问题,但是我很费解!

tanrui 2003-08-23 11:47:54
好像每天都在讨论页面上弹出对话框的问题,一种答案就是:
Reponse.Write("<script>window.alert(\"消息\")</script>");
但是我一这样写,就报错:
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

Source Error:



Line 86: {
Line 87: err.Visible=true;
Line 88: Reponse.Write("<script>window.alert(\"消息\")</script>");
Line 89: }
Line 90: else

这是怎么回事啊?

...全文
59 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
tanrui 2003-08-25
  • 打赏
  • 举报
回复
后两人说的是对的。
有可能是这样:如果是写在页面里,由于asp页对<script>这样的串比较敏感,所以有问题;
要是写在后代码里就没有问题了。

写在页面里的话,分开写就行了。
layershow 2003-08-24
  • 打赏
  • 举报
回复
这个问题的中文错误应该是
常数中有换行符. <--大概就是这样
你就把这一行删掉.再重新写一遍应该就好了
一般是可能不小心加上了什么不可见字符造成的错误
还不行就分开写试试
Response.Write("<script>");
Response.Write("window.alert(......);
这样分成多个语句
cnhgj 2003-08-24
  • 打赏
  • 举报
回复
你肯定将代码写在<script runat="server"></script>中了,对吗?
如果事的话,要把<script>分开,不然会出错

Reponse.Write("<scr" + "ipt>window.alert(\"消息\")</scr" + "ipt>");
New_bug 2003-08-24
  • 打赏
  • 举报
回复
我这边用你的一样的语句一点错都没有:)
Response.Write("<script>window.alert(\"消息\")</script>");//你的语句,测试通过
//以下测试都能通过
Response.Write("<script language=jscript>window.alert(\"消11息\")</script>");
Response.Write("<script language=jscript>window.alert('消22息')</script>");

我是放在page_Load中测试的:)
tanrui 2003-08-23
  • 打赏
  • 举报
回复
是我刚才写错了,但是我以前是有这样的问题,我改过来了,但是还有问题:

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

Source Error:



Line 86: {
Line 87: err.Visible=true;
Line 88: Response.Write("<script>window.alert(\"消息\")</script>");
Line 89: }
Line 90: else

layershow 2003-08-23
  • 打赏
  • 举报
回复
Reponse.Write("<script>window.alert(\"消息\")</script>");
Response

打错了

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧