好像每天都在讨论页面上弹出对话框的问题,一种答案就是:
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
这是怎么回事啊?
你肯定将代码写在<script runat="server"></script>中了,对吗?
如果事的话,要把<script>分开,不然会出错
Reponse.Write("<scr" + "ipt>window.alert(\"消息\")</scr" + "ipt>");
这个问题的中文错误应该是
常数中有换行符. <--大概就是这样
你就把这一行删掉.再重新写一遍应该就好了
一般是可能不小心加上了什么不可见字符造成的错误
还不行就分开写试试
Response.Write("<script>");
Response.Write("window.alert(......);
这样分成多个语句