In-Depth

VSLive! 2007: ASP.NET AJAX Under the Hood

Scott Cate illustrates how to implement key features of ASP.NET AJAX to a packed crowd at VSLive! San Francisco 2007.

AJAX to a packed crowd at VSLive! San Francisco 2007.
by Peter Varhol

Watch the video of the session! (Running time: 1 hour 2 minutes)

Scott Cate
President
myKB.com, Inc.

The VSLive! San Francisco 2007 session by Scott Cate on Microsoft's ASP.NET AJAX would have been standing-room only, except there wasn't room available to stand. Over 200 attendees were crammed into the conference room, making it one of the most popular breakout sessions at the event. Cate didn't disappoint the crowd, using only three content-free PowerPoint slides and five minutes before he drove directly into the code.

The key to ASP.NET AJAX on the client, according to Cate, is the use of the UpdatePanel control. By wrapping any control with the UpdatePanel, you make its data available to asynchronous updates. If the UpdateMode property of the UpdatePanel control is set to Always, then the UpdatePanel control's content is updated on every postback that originates from the page. This includes asynchronous postbacks from controls that are inside other UpdatePanel controls and postbacks from controls that are not inside UpdatePanel controls.

Cate illustrated this principle using a DataGrid control in an application. He wrapped a DataGrid control with an UpdatePanel in an ASP.NET 2.0 application and demonstrated that any updates to the grid did not require a refresh of the entire page. Rather, the update was processed asynchronously back to the server and the value alone was refreshed on the page.

You can use multiple UpdatePanel controls to update different page regions independently. When the page that contains one or more UpdatePanel controls is first rendered, all the content in the UpdatePanel controls is also rendered and sent to the browser. On subsequent asynchronous postbacks, the content of each UpdatePanel control might not be updated depending on the panel settings and on client or server logic for individual panels.

You can illustrate this principle in an example ASP.NET 2.0 page, by taking two identical controls and wrapping one of them in an UpdatePanel. Making the same change to both controls shows that the control using the UpdatePanel updates more quickly and seamlessly, without a page update. The other control requires a full page refresh, no matter how trivial the change.

The popularity of Cate's session says a lot about the growing popularity of AJAX among developers in general, and Visual Studio developers in particular. AJAX, which allows asynchronous updates through the use of scripting, is rapidly becoming a standard for usability in Web applications. Microsoft's ASP.NET AJAX framework provides you with an easier way of achieving this standard in Visual Studio—forget about manually writing scripts.

About the Author

Peter Varhol is the executive editor, reviews of Redmond magazine and has more than 20 years of experience as a software developer, software product manager and technology writer. He has graduate degrees in computer science and mathematics, and has taught both subjects at the university level.

comments powered by Disqus

Featured

Subscribe on YouTube