日期:2014-05-19  浏览次数:20742 次

在CS代码中调用script定义的函数问题
在页面 <script> 中定义了函数a(),在CS代码中用Response.Write( " <script> a() </script> ");调用无效,该怎样调用?另外在a()中有语句var   returnVal   =   window.showModalDialog( "xxxx.aspx ",window, "dialogWidth:450px;dialogHeight:150px ");总提示页面错误:缺少标识符?

------解决方案--------------------
正确的从服务器端向页面注入脚本的方法为:this.Page.RegisterClientScriptBlock(string Key,string Script) 而且注意在script中需要language属性。
使用response.write会破坏页面的解析结构。
答题完毕,希望是楼主想要的。
------解决方案--------------------
你要跳转页面阿?
------解决方案--------------------
关键是看你怎么调用了,通常这个是要在按钮的onclick实践中调用的
onclick= "a(); "


var returnVal = window.showModalDialog( "xxxx.aspx ",window, "dialogWidth:450px;dialogHeight:150px ");
把双引号换成单引号吧
------解决方案--------------------
http://dotnet.aspx.cc/article/49ml4ao8-5pb3-4kny-njzd-ljoioxv4m1x4/read.aspx
------解决方案--------------------
正确的从服务器端向页面注入脚本的方法为:this.Page.RegisterClientScriptBlock(string Key,string Script) 而且注意在script中需要language属性。
使用response.write会破坏页面的解析结构。
答题完毕,希望是楼主想要的。
-------------------------------------------------
只要实现没管破坏页面
OnClientClick= "a(); "
------解决方案--------------------
1、 <script> function a(){} </script> 要写在 <head> </head> 里面
2、Response.Write( " <script> a(); </script> ");不能写在page_load里面