Menu:

Recent Entries

Categories

Archives

Links

Blogs
- Dflying's Night
- David's Untitled Life
- Dflying's Blog in Chinese

This blog is hosted by DreamHost!

Syndicate

RSS 0.90
RSS 1.0
RSS 2.0
Atom 0.3

Introduction to Atlas UpdatePanel

Dflying | 24 March, 2006 20:08

UpdatePanel is so important an Atlas control that connects the traditional ASP.NET application and the new Web 2.0 AJAX implementation. That is, if you own applications wrote by ASP.NET, you do not need to take many changes to get it runs as the cool AJAX way by using UpdatePanel. Or, if you are not familiar with the whole branch of AJAX staffs such as JavaScript/DOM, UpdatePanel provides you a very simple way to use AJAX by warping you dynamic contents in an UpdatePanel, just like the Magic AJAX Framework does.


What you need to update your ASP.NET application to AJAX is just following steps:

  1. Create your form just using ASP.NET without any ideas about AJAX
  2. Add a ScriptManager object to the page and set EnablePartialUpdates=true
  3. Add an UpdatePanel around the section you want updated without PostBack
  4. Add some Event Triggers to the UpdatePanel to trigger the AJAX update action

And that’s all. You never need to know about the XMLHTTPRequest or ActiveX object, neither the mass of client side JavaScript or how to communicate with server logics.

Atlas UpdatePanel basically goes back to the server and runs the page as it normally would, but when it comes time to render the ScriptManager is just going to render only the UpdatePanel content plus the page header, including the all important ViewState of course. Simple and amazing.
There are a few things you may missing when using this simple AJAX way:

You must set EnablePartialUpdates=true in your ScriptManager. Then the ScriptManager can run the __doPostBack(something) JavaScript PostBacks warped in UpdatePanel in Async mode, which is the AJAX way. Otherwise you will just get the traditional full page PostBack with all page refreshed.

Then, there are two kinds of Triggers to fire a AJAX PostBack.

At last, UpdatePanel has two ways of updating: Mode=”Always” which is the default and Mode=” conditional”.

Here is a piece of demo code for UpdatePanel

<atlas:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server" />
<atlas:UpdatePanel ID="up1" runat="server">
  <Triggers>
     <atlas:ControlValueTrigger ControlID="dropDownList1" PropertyName="SelectedValue" />
     <atlas:ControlEventTrigger ControlID="button1" EventName="Click" />
  </Triggers>
  <ContentTemplate>
     Content Here. e.g. TextBox, GridView
  </ContentTemplate>
</atlas:UpdatePanel>

Two other cool features for you to play with while the UpdatePanel are: UpdateProgress control and error handling. When you add an UpdateProgress control to the page it automatically shows while the AJAX callback is in processing. You can embed au "updating" text message or an animated .gif in there to easily provide visual feedback for users (no need to write JavaScript code either). The error handling stuff also makes it much easier to handle errors at runtime (which today can be a mess with a lot of AJAX solutions, including the Windows Live Mail).

Posted in Atlas. Comment: (0). Trackbacks:(193). Permalink
«Next post | Previous post»

Referers

Comments

Leave a Reply

Auth Image