How can i call javascript function from backend within updatepanel
How can I call javascript function from backend within updatepanel in as开发者_Python百科p.net.
ScriptManager.RegisterStartupScript(this,yourUpdatePanel.getType(),"Your js",true);
see 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 ;)
精彩评论