ScriptManager.RegisterStartupScript用法
ScriptManager.RegisterStartupScript用法一、语法
public static void RegisterStartupScript(
Control control,
Type type,
string key,
string script,
bool addScriptTags
)
二、参数说明
1、control
为要注册脚本的控件ID。
2、type
为注册脚本控件类型,是控件还是this的GetType()都可以,typeOf(string)也没问题.
3、key
为脚本函数的名字,随便起。
4、script
为脚本内容。
5、addScriptTags
为标明是否再添加脚本标签,如果第四个参数里包含了<script></script>标签,此处则为false,否则为true。
三、实例
ScriptManager.RegisterStartupScript(this.Button1, this.GetType(), "alertScript", "alert('添加成功!');", true);
四、备注
多个RegisterStartupScript存在时,不能保证使用 RegisterStartupScript 注册的启动脚本块按照其注册顺序输出。 如果启动脚本块的顺序很重要,请使用 StringBuilder 对象将脚本块集中到一个字符串中,然后将它们作为单个启动脚本进行注册。