UpdatePanelDynamicallyUpdatedCS1.aspx 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <%@ Page Language="C#" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <script runat="server">
  5. protected void Page_Load(object sender, EventArgs e)
  6. {
  7. TheScriptManager.RegisterAsyncPostBackControl(DropDownList1);
  8. }
  9. protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  10. {
  11. switch (DropDownList1.SelectedValue)
  12. {
  13. case "DefaultView":
  14. MultiView1.SetActiveView(DefaultView);
  15. break;
  16. case "NewsView":
  17. MultiView1.SetActiveView(NewsView);
  18. break;
  19. }
  20. UpdatePanel1.Update();
  21. }
  22. </script>
  23. <html xmlns="http://www.w3.org/1999/xhtml">
  24. <head id="Head1" runat="server">
  25. <title>UpdatePanel Update Method Example</title>
  26. <style type="text/css">
  27. a
  28. {
  29. font-family: Arial;
  30. font-size:small;
  31. }
  32. label.LabelHeaderStyle
  33. {
  34. font-size: medium;
  35. font-weight: bold;
  36. font-family: Arial;
  37. }
  38. div.PanelStyle
  39. {
  40. width: 300px;
  41. border-color: #404040;
  42. border-style: double;
  43. height: 150px;
  44. }
  45. #DefaultViewPanel
  46. {
  47. background-color: #C0C0FF;
  48. }
  49. #NewsViewPanel
  50. {
  51. background-color: #C0FFC0;
  52. }
  53. </style>
  54. </head>
  55. <body>
  56. <form id="form1" runat="server">
  57. <div>
  58. <asp:ScriptManager ID="TheScriptManager"
  59. runat="server" />
  60. <asp:UpdatePanel ID="UpdatePanel1"
  61. UpdateMode="Conditional"
  62. runat="server">
  63. <ContentTemplate>
  64. <asp:MultiView ID="MultiView1"
  65. ActiveViewIndex="0"
  66. runat="Server">
  67. <asp:View ID="DefaultView"
  68. runat="Server">
  69. <asp:Panel ID="DefaultViewPanel"
  70. CssClass="PanelStyle"
  71. runat="Server" >
  72. <asp:Label ID="DefaultLabel1"
  73. Text="The Default View"
  74. AssociatedControlID="DefaultView"
  75. CssClass="LabelHeaderStyle"
  76. runat="Server">
  77. </asp:Label>
  78. <asp:BulletedList ID="DefaultBulletedList1"
  79. BulletStyle="Disc"
  80. DisplayMode="Hyperlink"
  81. Target="_blank"
  82. runat="Server">
  83. <asp:ListItem Value="http://www.microsoft.com">
  84. Today's Weather</asp:ListItem>
  85. <asp:ListItem Value="http://www.microsoft.com">
  86. Today's Stock Quotes</asp:ListItem>
  87. <asp:ListItem Value="http://www.microsoft.com">
  88. Today's News Headlines</asp:ListItem>
  89. <asp:ListItem Value="http://www.microsoft.com">
  90. Today's Featured Shopping</asp:ListItem>
  91. </asp:BulletedList>
  92. </asp:Panel>
  93. </asp:View>
  94. <asp:View ID="NewsView"
  95. runat="Server">
  96. <asp:Panel ID="NewsViewPanel"
  97. CssClass="PanelStyle"
  98. runat="Server">
  99. <asp:Label ID="NewsLabel1"
  100. Text="The News View"
  101. AssociatedControlID="NewsView"
  102. CssClass="LabelHeaderStyle"
  103. runat="Server">
  104. </asp:Label>
  105. <asp:BulletedList ID="NewsBulletedlist1"
  106. BulletStyle="Disc"
  107. DisplayMode="Hyperlink"
  108. Target="_blank"
  109. runat="Server">
  110. <asp:ListItem Value="http://www.microsoft.com">
  111. Today's International Headlines</asp:ListItem>
  112. <asp:ListItem Value="http://www.microsoft.com">
  113. Today's National Headlines</asp:ListItem>
  114. <asp:ListItem Value="http://www.microsoft.com">
  115. Today's Local News</asp:ListItem>
  116. </asp:BulletedList>
  117. </asp:Panel>
  118. </asp:View>
  119. </asp:MultiView>
  120. </ContentTemplate>
  121. </asp:UpdatePanel>
  122. <br />
  123. </div>
  124. <asp:DropDownList ID="DropDownList1"
  125. AutoPostBack="True"
  126. OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
  127. runat="server">
  128. <asp:ListItem Value="DefaultView">
  129. Default View</asp:ListItem>
  130. <asp:ListItem Value="NewsView">
  131. News View</asp:ListItem>
  132. </asp:DropDownList>
  133. </form>
  134. </body>
  135. </html>