Reputation: 21
How can I call javascript function from backend within updatepanel in asp.net.
Upvotes: 2
Views: 820
Reputation: 77
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 ;)
Upvotes: 0
Reputation: 17931
ScriptManager.RegisterStartupScript(this,yourUpdatePanel.getType(),"Your js",true);
see http://msdn.microsoft.com/en-us/library/bb310408.aspx
Upvotes: 2