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

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-04   浏览: 414 ::
收藏到网摘: 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>");

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