default.aspx 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 Button1_Click(object sender, EventArgs e)
  6. {
  7. System.Threading.Thread.Sleep(4000);
  8. Label1.Text = "Last update from server " + DateTime.Now.ToString();
  9. }
  10. protected void Button2_Click(object sender, EventArgs e)
  11. {
  12. System.Threading.Thread.Sleep(1000);
  13. Label2.Text = "Last update from server " + DateTime.Now.ToString();
  14. }
  15. </script>
  16. <html xmlns="http://www.w3.org/1999/xhtml">
  17. <head id="Head1" runat="server">
  18. <title>Postback Precedence Example</title>
  19. <style type="text/css">
  20. body {
  21. font-family: Tahoma;
  22. }
  23. #UpdatePanel1, #UpdatePanel2 {
  24. width: 400px;
  25. height: 100px;
  26. border: solid 1px gray;
  27. }
  28. div.MessageStyle {
  29. background-color: #FFC080;
  30. top: 95%;
  31. left: 1%;
  32. height: 20px;
  33. width: 600px;
  34. position: absolute;
  35. visibility: hidden;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <form id="form1" runat="server">
  41. <div>
  42. <asp:ScriptManager ID="ScriptManager1" runat="server">
  43. <Scripts>
  44. <asp:ScriptReference Path="PostBackPrecedence.js" />
  45. </Scripts>
  46. </asp:ScriptManager>
  47. <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="Server" >
  48. <ContentTemplate>
  49. <strong>UpdatePanel 1</strong><br />
  50. This postback takes precedence.<br />
  51. <asp:Label ID="Label1" runat="server">Panel initially rendered.</asp:Label><br />
  52. <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />&nbsp;
  53. <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
  54. <ProgressTemplate>
  55. Panel1 updating...
  56. </ProgressTemplate>
  57. </asp:UpdateProgress>
  58. </ContentTemplate>
  59. </asp:UpdatePanel>
  60. <asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" runat="Server" >
  61. <ContentTemplate>
  62. <strong>UpdatePanel 2</strong><br />
  63. <asp:Label ID="Label2" runat="server">Panel initially rendered.</asp:Label><br />
  64. <asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
  65. <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel2">
  66. <ProgressTemplate>
  67. Panel2 updating...
  68. </ProgressTemplate>
  69. </asp:UpdateProgress>
  70. </ContentTemplate>
  71. </asp:UpdatePanel>
  72. <div id="AlertDiv" class="MessageStyle">
  73. <span id="AlertMessage"></span>
  74. </div>
  75. </div>
  76. </form>
  77. </body>
  78. </html>