Partial Rendering Misses AJAX Architectural Points

Published 19 September 07 09:19 AM | despos

Partial rendering is one of the two approaches that ASP.NET AJAX propounds. It works by applying the Interceptor pattern and hooking up the submit event of the form. The event handler then kicks in and operates the intercepted request via XMLHttpRequest instead of going through the browser. From the perspective of the ASP.NET runtime, business is as usual. So the request goes through the usual lifecycle and fires Init and Load events, and handles the postback and updates the viewstate. Undoubtedly, it keeps flickering out of pages and contributes to an overall greatly improved user experience. Undoubtedly, it is relatively cheap both in terms of required skills and impact on existing code. Properly optimized, it can lead to significant bandwidth improvement.

Should we call this AJAX?

AJAX is about a change of paradigm for the Web where we place requests-for-data instead of submitting forms-for-pages. Nothing of this happens with partial rendering. So should still we call this AJAX? And, frankly, does it really matter? Architecturally speaking, partial rendering is not AJAX for the simple reason that the underlying application model remains the same. There's no new architectural point in partial rendering. But partial rendering remains an excellent way to enhance existing applications.

Can we simply conclude with a sounding "Who cares if it's not pure AJAX?"

Partial rendering still misses some of the key features of AJAX--one in particular. So a model that doesn't support concurrent async operations, should be labeled as pure AJAX? I don't know whether we should or not. Partial rendering has many strengths, including that of simplifying the development of an AJAX-based user interface. However, it doesn't allow concurrent async calls. If you place two consecutive clicks for postback and the second fires before the former has terminated, then the ongoing call is aborted to make room for the second. Why is it so? To avoid breaking the viewstate and the overall consistency of the state. On the other hand, the pre-AJAX web works by making one call at a time. Why should partial rendering then be different?

What does it mean to you?

Use partial rendering whenever you feel, but be aware of its inherent limitations. In practice it mostly means that you have to disable all controls that can fire a postback during a refresh. If you need multiple calls at the same time, use then script services and trigger them entirely on the client via JavaScript. And as a free additional tip, avoid doing polling via partial rendering. In other words, avoid the use UpdatePanel with Timer controls, unless strictly necessary or if it's the minor evil. The issues are viewstate and bandwidth. Potentially too much data moving over the wire too frequently. A script service commanded by a client-side timer (the old faithful window.setTimeout) would do the job more efficiently.
 

Filed under:

Comments

# David Taylor said on September 19, 2007 04:21 AM:

Hi Dino,

You are absolutely correct about the main issue being the lack of async support when using update panels - which is of course due to the architecture of ASP.NET.  But it is still a wonderful model for the majority of an application framework.

ASP.NET is now so well built out I would say it provides many more 'features' for building a large site than if you even attempted to build everything in silverlight 1.1 with just a wrapper html page.

For my new project targeting a delivery date of late 2008, I plan to build the bulk of the site in ASP.NET 3.5, along with all the features of ASP.NET like UserControls, MasterPages, Themes, UpdatePanels (etc) and then use SilverLight 1.1 whenever I have functionality on a page that is very 'chatty' with the server and/or needs better interaction.

Yes...I am taking a bet that Silverlight will be widely distibuted now it will be supported on Mac, Windows and Linux.  I also think Microsoft has the right strategy to focus initially on media content to get Silverlight deployed widely.  I remember I never installed quicktime until it was the only way I could watch the starwars trailers ;-)

I think that is the best of both works, as you get an amazingly well built out and structured overall framework with ASP.NET 3.5 but can use SilverLight 1.1 for the interactive and chatty part.

You will note I will not need to write and more importantly debug much, if any javascript with this solution :-)

Sorry about your back.

# Coleman said on September 19, 2007 08:18 AM:

Dino - Thanks for the obvious.  I agree and get your point... but didn't you write a book on this stuff explaining how to do the same simple stuff on the same old simple web site?  Aren't you kind of biting the hand that feeds?  

How about a new book on MS-AJAX taking all of this into consideration without any mention of an UpdatePanel other than in the first chapter explaining why you are not writing about the simple stuff.  

Further more, explain how you will handle more complex topics of dealing with a million plus records and not being able to cache the entire DataSet on the web server.  I've read your books Dino and like them... but come on... walk the walk !!!

# Nullable said on September 19, 2007 10:05 AM:

Dino, you're a beautiful man! That's a great post, and a hard battle to fight.

Sometimes people misunderstand posts like this (as is seen in the above comment by Coleman), but professionals appreciate the work that Microsoft is doing, and evangelizers like yourself.

# Coleman said on September 19, 2007 11:55 AM:

Nullable - That is my point.  Dino is an MS evangelizer.  I get his point and agree with it... but read his books.  It doesn't take a professional to write a youth soccer league site or bind to a SqlDataSource throwing your SQL on the web server...

# ThemePassion - Best stuff about design! » Partial Rendering Misses AJAX Architectural Points said on September 19, 2007 06:15 PM:

Pingback from  ThemePassion - Best stuff about design! » Partial Rendering Misses AJAX Architectural Points

# DotNetKicks.com said on September 20, 2007 02:00 AM:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# Tim said on September 21, 2007 12:04 PM:

It's still using Asynchronous JavaScript And XML isn't it?

So it only allows one call at a time. IIRC, you're only allowed TWO open calls to a server anyway.

# Paul Ballard said on September 22, 2007 07:17 PM:

Dino,

I concur with your opinion that just using UpdatePanels (partial rendering) misses the boat on the power of AJAX.  I wrote a blog post comparing the development model capable in AJAX to more traditional Smart Client development.

My opinion is that that tooling for this paradigm shift hasn't occurred.  Rather, we've been given a way to create "demoware" with the majority of the real work requiring mountains of hand coded Javascript.  SilverLight on the other hand is tooled as a major shift in paradigm and so will probably end up being a more powerful platform for web based applications.  Of course that's just my opinion, I could be wrong.

Paul

# Harish Nair said on September 28, 2007 11:48 PM:

hi all,

I totally agree to what Dino has wrote above and it is definitely just a honest disclosure on what MS does with AJAX.net controls and this was exactly what I was looking over the net.  We [at our firm] had created the AJAX js library for our internal use and had come to know of the intense use of javascript that is involved other than the server side coding.

From the comments above, I came to this conclusion.

If you have time at your leisure, then go for an AJAX technology which is totally legacy and lets you make multiple requests async, and something which follows JSON..but if you are short on time [which normally people are] on projects, go for ASP.NET AJAX controls, drop the update panels and other controls that MS offers, and just implement it.  Just let the other guy know that you wont allow multiple request!!!

Thanks. I was looking for some article to back my decision and it seems like this is the best way out.

regards

harish

# jorgebg said on October 11, 2007 09:33 AM:

I couldn't agree with you more.

Leave a Comment

(required) 
(required) 
(optional)
(required)