您的位置:首页 > 编程语言 > ASP

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


)



参数

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查了..
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐