If you’ve ever worked in asp.net you have probably ran into update panels (<asp:UpdatePanel></asp:UpdatePanel>) which is microsoft’s way of allowing ajax postbacks to occur for desktop developers. Has anyone seen how much javascript gets produced and the amount of data that gets sent on the post of these things? It’s horrendous, but that’s another post.
My need was to do some validation of returned values inside of the UpdatePanel. Instead of searching through all the magically created JavaScript to figure out what method is doing what or to find the ajax call to do what you need on completion, you can add a hook.
As far as I can see this is available in .net 3.5 and higher, so if you are using something earlier than that, let me know if it works for you. In your .aspx page inside your script tags you would add -Sys.WebForms.PageRequestManager.getInstance().add_endRequest(myJavascriptFunction)
<script type=”text/javascript”>
function iAmReallyCool(){
alert(‘for sure!’);
}
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(iAmReallyCool);
</script>
<asp:UpdatePanel id=”yourid” runat=”server”>
// your asp.net stuff in here
</asp:UpdatePanel>
So whenever your postback is done .net now knows to run the javascript function iAmReallyCool(). Now if you are going to do anything with the data that is returned from the postback on the page, remember you will have to recall the DOM because the updatePanel is new and is not in memory. If you are using JQuery you would use the .live function.
Learn the foundation of the DHTMLX Suite quickly while building a single page application with multiple components in harmony.
How often do you work with tables? I work with them quite a bit and styling t read more...
UPDATE!! A plugin is now available for this tutorial that includes more features read more...
When running a site with a boat load of javascript, you may want to run a script read more...
There seems to be a lot of misconceptions on the difference between the document read more...
Greetings All! Since everyone was digging the Star Comment Rating I decided that read more...