简体   繁体   中英

How can i call javascript function from backend within updatepanel

如何在asp.net 的updatepanel 中从后端调用javascript 函数。

ScriptManager.RegisterStartupScript(this,yourUpdatePanel.getType(),"Your js",true);

请参阅http://msdn.microsoft.com/en-us/library/bb310408.aspx

Its not hard to do, but it's depends on you, how you can call a method/function,

1) without update panel

 function welcome() { alert("Welcome Guys!"); } protected void Page_Load(object sender, EventArgs e) { ClientScript.RegisterStartupScript(Page.GetType(), "OnLoad", "welcome();", true); }

2) With update panel

 function welcome() { alert("Welcome Guys!"); } protected void Page_Load(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(Page, GetType(), "JsStatus","welcome();", true); }

both are perfectly works ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM