asp.net ajax后台使用JS脚本.需要使用ScriptManager..::.RegisterStartupScript 方法
2012-03-06 17:44
936 查看
在使用asp.net ajax时.
如果需要在后台使用JS.
用以前的 response.write("<script>...</script>");这样的方式
是会报错的..
这里就需要使用 ScriptManager.RegisterStartupScript 方法
ScriptManager.RegisterStartupScript 方法 (Control, Type, String, String, Boolean)
C#语法:
C#语法
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
public static void RegisterStartupScript(
Control control,
Type type,
string key,
string script,
bool addScriptTags
)
正在注册该客户端脚本块的控件。
type 类型:System..::.Type
该客户端脚本块的类型。通常使用 typeof 运算符 (C#) 或
GetType 运算符 (Visual Basic) 来指定该参数,以检索正在注册该脚本的控件的类型。
key 类型:System..::.String
该脚本块的唯一标识符。
script 类型:System..::.String
脚本。
addScriptTags 类型:System..::.Boolean
如果用 " sdata="langKeyword"></script> 标记括起该脚本块,则为
true;否则为
false。
其他的语法,自己上msdn查了..
如果需要在后台使用JS.
用以前的 response.write("<script>...</script>");这样的方式
是会报错的..
这里就需要使用 ScriptManager.RegisterStartupScript 方法
ScriptManager.RegisterStartupScript 方法 (Control, Type, String, String, Boolean)
C#语法:
C#语法
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
public static void RegisterStartupScript(
Control control,
Type type,
string key,
string script,
bool addScriptTags
)
参数
control 类型:System.Web.UI..::.Control正在注册该客户端脚本块的控件。
type 类型:System..::.Type
该客户端脚本块的类型。通常使用 typeof 运算符 (C#) 或
GetType 运算符 (Visual Basic) 来指定该参数,以检索正在注册该脚本的控件的类型。
key 类型:System..::.String
该脚本块的唯一标识符。
script 类型:System..::.String
脚本。
addScriptTags 类型:System..::.Boolean
如果用 " sdata="langKeyword"></script> 标记括起该脚本块,则为
true;否则为
false。
其他的语法,自己上msdn查了..
相关文章推荐
- ScriptManager.RegisterStartupScript()方法在asp.net ajax页面无效的解决方法
- 在ASP.NET AJAX中,由于一个ASPX页面上只能有一个ScriptManager控件,所以在有母版页的情况下,如果需要在Master-Page和Content-Page中需要引入不同的脚本时,这就需要在Content-page中使用ScriptMa
- ASP.net 中 使用ClientScript.RegisterStartupScript() 注册脚本
- 在asp.net ajax中替代ClientScript.RegisterStartupScript()的方法
- .Net后台使用RegisterClientScriptBlock和RegisterStartupScript调用前台的JS 区别
- [原]ASP.NET中使用JQUERY-EASYUI后,解决ClientScript.RegisterStartupScript 所注册脚本执行两次
- ASP.NET AJAX 's UpdatePanel 中使用Page.ClientScript.RegisterStartupScript 失败
- ASP.NET中后台注册js脚本使用的方法对比
- ASP.NET AJAX 's UpdatePanel 中使用Page.ClientScript.RegisterStartupScript 失败
- UpdatePanel中使用脚本文件(ScriptManager.RegisterStartupScript 方法)
- ASP.NET 使用ajaxupload.js插件出现上传较大文件失败的解决方法
- 微软ASP.Net Ajax:使用AJAX直接调用后台页面类方法
- 微软ASP.Net Ajax:使用AJAX直接调用后台页面类方法
- ASP.Net Ajax应用初步:使用AJAX直接调用后台方法
- AjaxPro.dll,asp.net 前台js调用后台方法(无刷新)
- AjaxPro.dll,asp.net 前台js调用后台方法(无刷新)
- 微软ASP.Net Ajax:使用AJAX直接调用后台页面类方法
- AjaxPro.dll,asp.net 前台js调用后台方法(无刷新)
- AjaxPro.dll,asp.net 前台js调用后台方法(无刷新)