ASP.NET AJAX Tips & Tricks
My final session of Tuesday was a deep dive on ASP.NET AJAX, with Jeff Prosise, co-founder of Wintellect and Matt Gibbs, Development Manager at Microsoft.
Jeff and Matt did an excellent job of challenging the advanced AJAX guys while still engaging coders with less experience using the ASP.NET AJAX libraries. These two guys seemed to get along really well, and (are you sitting down?) the banter between them was friendly and funny... not that common of a combination from my experience with major conference presentations. The expertise of ASP.NET AJAX they showed by easily handling difficult questions sold me, I'll be checking their blogs from now on.
Code-wise, these two didn't so much deep dive into one particular example, but instead provided "seed" information that I plan to research after the conference. In fact, I left not quite sure what specific points I could write about here, but I am positive that I just accumulated a lot of great tips & tricks that may come up with my clients in the future. A few tips:
- When using multiple UpdatePanels per page, start getting into the habit of setting the UpdateMode flag to "Conditional". This prevents non-updated panels from sending their contents (viewstate, etc) up the pipe. No need to send this traffic unless the content needs to be updated, right? Keep in mind that with this method, if UpdatePanel A needs to update whenever UpdatePanel C is changed, you'll have to explicitly call UpdatePanel A's Update method in the managed code (example: PanelA.Update();)
- Immediately go and download Nikhil Kothari's Web Development Helper Utility. What a great tool for watching your asynch postbacks firing client-server: turn logging on and start reducing your traffic size.
- The ASP.NET AJAX library .pdb files are now available, add 'em to your project to allow debugging into the libraries themselves. Email Matt if you see any bugs.
- I will forever be stealing the phrase "New it up" to mean instantiating an object. It's stuck in my head forever, much like Bonnie Tyler's "Total Eclipse of the Heart".
- An UpdatePanel's brain actually lies within the System.WebForms.PageRequestManager class, so take a look at leveraging it's events to manipulate your partial page updates:
var mgr = System.WebForms.PageRequestManager.getInstance();
mgr.add_InitializeRequest(InitRequest);
function InitRequest(sender, args) {
args.set_Cancel(!confirm('Really postback?'));
}
Even though this example isn't very real-world, you could use something like this to prioritize async calls, preventing a more important in-progress request from being cancelled by a subsequent one. Jeff also used a similar method to draw attention to an updated content area after the asynch postback completed. Related docs:ASP.NET AJAX PageRequestManager doc
Great job, guys. Turn around, bright eyes...