2007-08-30
| Table of Contents: |
| Rate This Article: | Add This Article To: |
( Page 2 of 3 )
Using the AJAX Extensions
The AJAX extensions re included in Visul Studio 2008. While in Visul Studio 2005 you hd to downlod nd instll them, they re prt of the Visul Studio 2008 instlltion. The AJAX extensions cn be found in the Toolbox in the section lbeled AJAX Extensions s shown in the following figure.
Creting Our First AJAX Web Appliction
It’s time to get strted with AJAX. We’ll crete our first AJAX web site.
To crete new AJAX-enbled Web site, follow these steps:
1. Choose FileÍNew Web Site.
4.Click OK to crete the ASP.NET Web site.
The defult.spx pge opens in Split view.
5. From the AJAX extensions tb of the Toolbox, plce one nd only one ScriptMnger object into the form in the Design view.
Tht’s ll you need to do in order to crete n AJAX-enbled web site. We’ll now spend some time exploring this ppliction by dding nd modifying it to illustrte importnt concepts.
Adding Some Trditionl ASP.NET Controls to the Form
We’ll strt off by dding three lbels nd button to the form. These re trditionl ASP.NET controls. We’ll get these working nd tke look t this simple ppliction first, though, before going on to implement prtil pge updte pttern.
Using AJAX to Implement Prtil Pge Updte Pttern
Now tht we hve n ASP.NET ppliction working, we’ll use AJAX to implement prtil pge updte pttern. The end result will be tht the button will cuse n updte only for the second lbel.
Updting Controls From Outside of n UpdtePnel
There might be times when you need to do prtil pge updtes when the control tht fires off the updte cn’t be inside of the UpdtePnel. We’ll modify our ppliction once gin, nd tke the button out of the UpdtePnel. Then, we’ll dd Triggers collection to the UpdtePnel. In the Triggers collection, we’ll specify tht the second lbel should be updted by the button, even though the button is outside of the UpdtePnel.
4.Click on the Add button, fter which you’ll see tht n AsynPostBck member hs been dded.
5.In the right side of the editor set the controlID to Button1 nd the EventNme to Click. This wires up the buttons click event to the UpdtePnel’s updte.
6.Click on the Add button, fter which you’ll see tht n AsynPostBck member hs been dded.
7.Run the progrm by pressing Ctrl+F5. You’ll see the lbels reflect the time of the first pge lod, then only the second lbel is updted in response to button click even though it’s no longer in the UpdtePnel s shown in the following figure.
![]() |
|


