C# 如何从.cs文件调用多个jquery函数?
我有两个JQuery函数,我想从PageLoad事件调用它们。目前的执行情况如下:C# 如何从.cs文件调用多个jquery函数?,c#,jquery,asp.net,C#,Jquery,Asp.net,我有两个JQuery函数,我想从PageLoad事件调用它们。目前的执行情况如下: ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "Function1();", true); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "Function2();", true); 问题是,第一个函数被调用
ScriptManager.RegisterStartupScript(this.Page, this.GetType(),
"script", "Function1();", true);
ScriptManager.RegisterStartupScript(this.Page, this.GetType(),
"script", "Function2();", true);
问题是,第一个函数被调用,即Function1而不是Function2
如果更改调用顺序,则调用Function2而不是Function1
如何执行这两个函数
提前感谢。您可能正在用“稍后”覆盖上一个脚本块,因为调用中的两个块都有相同的键
script
。为每个脚本块指定唯一的名称,例如,将第一个块命名为script1
,将第二个块命名为script2
将允许您调用这两个函数
SriptManager.RegisterStartupScript(this.Page, this.GetType(), "script1", "Function1();", true);
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script2", "Function2();", true);
在这个特定的场景中,您不需要两次注册脚本块,而是可以在一个RegisterStartupScript
中注册多个javascript语句
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script",
"Function1();Function2();", true);