How do I load a javascript command (like an onload or onclick or something) after the update panel was just refreshed.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Embed these lines on your javascript tag
function foo()
{
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
}
function endRequestHandler(sender, args)
{
// Do your stuff
alert('Update Panel routine is now complete');
}
Then, put this on you body tag
<body onload="foo()">
Method 2
ScriptManager.RegisterClientScriptBlock(upPanel, upPanel.GetType(), "alert('hello world')", true);
You must call this on partial postback.
Method 3
You could use ScriptManager. I’d think ScriptManager.RegisterClientScriptBlock should be useful. You can then execute JS after the page load. Other options include JQuery.live.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0