Do you agree that AJAX is a real breakthrough, making possible things that were impractical, if not impossible, before? I believe that anyone would agree to this statement.
Do you agree that AJAX is quite difficult and bothersome to implement without (but often also with) ad hoc programming tools such as libraries and controls? All in all, this statement is also hard to contradict.
Today's Web pages are cumbersome (or "rich" if you want to be polite). Such pages take a while to download and refresh; and having a significant set of interactive features, they tend to refresh quite often. The waiting time would even be valuable if only the new content could justify it. Instead, for the most part of it, the new content is just like the old content except some very small fragments. Any Web developer would agree on this point too.
However, any further perspectives and viewpoints will generate discussion -- sometimes heated -- among developers. Some developers believe that all you need is a mechanism in the Web development framework of choice that lets you refresh only the portion of the page that really requires updates. Other developers believe that to achieve this you must redesign your pages and applications from the ground up to follow the AJAX paradigm literally.
As a matter of fact, the AJAX paradigm turns out to be quite expensive to apply all the way through. For this reason, a simpler postback-based mechanism like ASP.NET Partial Rendering is an effective alternate approach. But how effective?
To evaluate the effectiveness of the process, let's review the amount of data being moved in the roundtrip.
During the upload of the request, a partial rendering operation adds some extra information not found in a regular postback. In particular, it adds an extra HTTP header and a new parameter in the form collection. Not really a big difference. The downloaded response may be significantly shorter, but some conditions affect the real size. The response is made of some fixed components -- the viewstate and other helper hidden fields such as EVENTVALIDATION -- plus variable-length content. The variable-length content contains the markup for only the portions of the page that have been updated during the request. Here are a few considerations:
- For pages with a very large viewstate, the difference is not significant because the large viewstate counts more than anything else. The viewstate is always returned entirely and it is never limited to only the controls really updated.
- To get the most out of partial rendering, you need to optimize your use of the viewstate.
- The size of the returned markup depends on the number and placement of UpdatePanel regions. Multiple but smaller UpdatePanels are preferable because they ould allow you to better restrict the area subject to dynamic updates. If a button doesn't change during a request, there's no reason for including it in an UpdatePanel, even though the same button is responsible for triggering the refresh of that UpdatePanel.
- Ideally, you should try to partition your page in non-overlapping UpdatePanel. However, this is not always possible.
In summary, there are many ways to set up a partial rendering operation within an ASP.NET page and minimize the amount of data being moved around. Does it really make a difference for the end user?
Partial rendering delivers some of the key benefits of AJAX, but it is just plain ASP.NET with a smarter and script-based management of the request. Actually, for the end user the big benefit of partial rendering is the perception of performance they experience when the page content is refreshed without any flickering in the whole page. Partial rendering delivers this AJAX benefit regardless of further optimizations.
The bottom line is that using partial rendering is effective because it neatly improves the user experience without much effort on the developer's side. Spending much time trying to further improve partial rendering by minimizing data transfer may result in tricky issues and even recommend a significant rearchitecture of the pages. Partial rendering is really effective if it is cheap to implement.