asp.net ajax后台使用JS脚本.需要使用ScriptManager..::.RegisterStartupScript 方法
在使用asp.net ajax时.
如果需要在后台使用JS.
用以前的 response.write("<script>...</script>");这样的方式
是会报错的..
这里就需要使用 ScriptManager.RegisterStartupScript 方法
ScriptManager.RegisterStartupScript 方法 (Control, Type, String, String, Boolean)
C#语法:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
参数
- 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。