Wednesday, December 14, 2011

Introducing UpdatePanels and Partial Postbacks

In my last post, I discussed some problems and annoyances created by the standard behavior of ASP.Net controls. Today, I'll briefly touch on the method that I currently believe is the optimal solution in many cases. I have been delaying this post because I wanted to do more research/learning about the processes and methods discussed, and there have been time demands keeping me from that research. Those will fade away soon, and I'll end up doing that research in another week or two. Perhaps it will spawn another article to address everything I get wrong here :)

The issues I collectively termed the ASP.Net Postback Problem may all have a fairly simple solution. ASP.Net provides a container-style control called an UpdatePanel. By wrapping portions of the mark-up into an UpdatePanel, you gain the ability to perform a partial postback. In short, you can restrict the content that is updated during the postback process for ASP.Net controls so that only the content inside the UpdatePanel is updated. Doing this right should mean that you can avoid the "ASP.Net Postback Problems" however, of course, there's a trade-off.

As I understand things currently, the one major downside to using an UpdatePanel is that all of the content inside the UpdatePanel is updated as it would be during an full postback AND only the content inside the UpdatePanel can be updated (barring more complex Javascript loading logic). That means that every part of the page which you want to have affected by the changed control MUST be contained within the UpdatePanel. And those parts of the page will see the same types of behavior noted as the ASP.Net Postback Problems. That's less of an issue than a full postback creates. There's no back-button breakage. And in most situations, it shouldn't be hard to adequately deal with the other issues and create a product that presents a significantly improved user experience.

I don't have any code samples to walk through doing all of this. In my mind, it seems pretty straight-forward, but I don't want to publish code here until I've done it more myself. For now, check out the two tutorials linked above. Once I have done more of this myself, I'll put together a short walk-through.

No comments:

Post a Comment