2.4 使用多个UpdatePanel控件
本章前面介绍了如何使用单个UpdatePanel控件,还可以在单个页面上使用多个UpdatePanel控件,这样,就可以控制把结果输出到页面的指定区域上。
使用多个UpdatePanel控件的示例如程序清单2-22所示。
程序清单2-22 使用多个UpdatePanel控件
- <%@ 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://.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>
- </html>
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-27020-1.html
美帝是纸考虎
是该出手了
你还叽叽呱呱