当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 代码前置时页面输出脚本的要注意的问题|

Javascript
Add a Table to a Word Document
Add Formatted Text to a Word Document
用jscript实现新建word文档
用jscript实现新建和保存一个word文档
Open and Print a Word Document
Use Word to Search for Files
Convert Seconds To Hours
Sample script that deletes a SQL Server database
Sample script that displays all of the users in a given SQL Server DB
firefox中用javascript实现鼠标位置的定位
div+css实现鼠标放上去,背景跟图片都会变化。
Locate a File Using a File Open Dialog Box
Save a File Using a File Save Dialog Box
用jscript实现列出安装的软件列表
List the Stored Procedures in a SQL Server database
Display SQL Server Login Mode
Display SQL Server Version Information
List all the Databases on a SQL Server
用jscript启动sqlserver
Stop SQL Server

Javascript 中的 代码前置时页面输出脚本的要注意的问题|


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-04   浏览: 416 ::
收藏到网摘: n/a

代码前置指的是把去掉.Cs文件,把所有的Cs文件中的代码都写在aspx或者ascx中

常常有时你需要在页面输出脚本,如果弹出一个提示框或者打开一个新窗口。。。

你会发现有时用

Page.RegisterStartupScript("openwin","<script>window.open('http://bew.com/Act/Dyp/xingfujz/xingfujz.aspx','_blank');</script>");

或者

Response.Write("<script language=javascript>window.open('http://bew.com/Act/Dyp/xingfujz/xingfujz.aspx','_blank');</script>");
会报错

编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。

编译器错误信息: CS1010: 常数中有换行符

源错误:

 

行 178:
行 179:            string showconent=“”
行 180:            Page.RegisterStartupScript("openwin","<script>window.open('http://bew.sihai.com/Act/Dyp/xingfujz/xingfujz.aspx','_blank');</script>");
行 181:            Page.RegisterStartupScript("ShowMessage",showconent);
行 182:
 

那是由于 解析程序遇到 </script>  时 认为时服务器端的代码结束了,所以报错!

解决方式是

Page.RegisterStartupScript("openwin","<script>window.open('http://bew.baihe.com/Act/Dyp/xingfujz/xingfujz.aspx','_blank');<" + "/script>");

把那个东东拆开就行了,呵呵