UpdatePanelUpdateMode2CS.aspx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <%@ Page Language="C#" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <script runat="server">
  4. protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  5. {
  6. if (DropDownList1.SelectedValue == "1")
  7. UpdatePanel1.Update();
  8. else if (DropDownList1.SelectedValue == "2")
  9. UpdatePanel2.Update();
  10. DropDownList1.SelectedIndex = 0;
  11. }
  12. </script>
  13. <html xmlns="http://www.w3.org/1999/xhtml">
  14. <head id="Head1" runat="server">
  15. <title>UpdatePanelUpdateMode Example</title>
  16. </head>
  17. <body>
  18. <form id="form1" runat="server">
  19. <div>
  20. <asp:ScriptManager ID="ScriptManager1"
  21. runat="server" />
  22. <asp:Panel ID="Panel1" runat="server" GroupingText="Panel 1">
  23. <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional"
  24. runat="server">
  25. <ContentTemplate>
  26. <p>
  27. UpdatePanel.Update() method is called if this panel is selected
  28. to be updated from DropDownList control. Last updated:
  29. <%= DateTime.Now.ToString()%>
  30. </p>
  31. </ContentTemplate>
  32. </asp:UpdatePanel>
  33. </asp:Panel>
  34. <asp:Panel ID="Panel2" runat="server" GroupingText="Panel 2">
  35. <asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional"
  36. runat="server">
  37. <ContentTemplate>
  38. <p>
  39. UpdatePanel.Update() method is called if this panel is selected
  40. to be updated from DropDownList control. Last updated:
  41. <%= DateTime.Now.ToString() %>
  42. <br />
  43. <br />
  44. <asp:DropDownList ID="DropDownList1" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
  45. runat="server">
  46. <asp:ListItem Text="Select a panel to update..." Value="0" Selected="True" />
  47. <asp:ListItem Text="Refresh Panel 1 and 2" Value="1" />
  48. <asp:ListItem Text="Refresh Panel just 2" Value="2" />
  49. </asp:DropDownList>
  50. </p>
  51. </ContentTemplate>
  52. </asp:UpdatePanel>
  53. </asp:Panel>
  54. </div>
  55. </form>
  56. </body>
  57. </html>