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> ... |
Get Professional ASP.NET 3.5 AJAX now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.