O'Reilly logo

Professional ASP.NET 3.5 AJAX by Matt Gibbs, Dan Wahlin, Bill Evjen, Dave Reed

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2.4. Using Multiple UpdatePanel Controls

So far, this chapter has showed you how to work with a single UpdatePanel control, but it is important to realize that you can have multiple UpdatePanel controls on a single page. This, in the end, will give you the ability to control the output to specific regions of the page when you want.

An example of using more than a single UpdatePanel control is presented in Listing 2-22.

Example 2-22. Using more than one UpdatePanel control
<%@ Page Language="C#" %> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Label1 was populated on " + DateTime.Now; Label2.Text = "Label2 was populated on " + DateTime.Now; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Multiple UpdatePanel Controls</title> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="Label1" runat="server"></asp:Label> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" /> </Triggers> </asp:UpdatePanel> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> <asp:Label ID="Label2" runat="server"></asp:Label> </ContentTemplate> </asp:UpdatePanel> <br /> <br /> <asp:Button ID="Button1" runat="server" Text="Click to initiate async request" OnClick="Button1_Click" /> </div> </form> </body> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required