Question:
I want to trigger some javascript function after a postback of my Asp.Net UpdatePanel. How do I do this?How to execute js after UpdatePanel postback?
Answer:
This is simple and standard.You register a function with the PageRequestManager EndRequest trigger.
The EndRequest is evidently called on each and every ajax request.
Here is an example
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);
function endRequest(sender, args)
{
// your code goes here
// you could handle your error here
if (args.get_error() != undefined) {
//$get('Error').style.visibility = "visible";
// Let the framework know that the error is handled,
// so it doesn't throw the JavaScript alert.
args.set_errorHandled(true);
}
}
</script>
No comments:
Post a Comment