default.aspx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 Button_Click(object sender, EventArgs e)
  6. {
  7. System.Threading.Thread.Sleep(3000);
  8. }
  9. </script>
  10. <html xmlns="http://www.w3.org/1999/xhtml" >
  11. <head id="Head1" runat="server">
  12. <title>UpdateProgress Example</title>
  13. <style type="text/css">
  14. #UpdatePanel1, #UpdatePanel2, #UpdateProgress1 {
  15. border-right: gray 1px solid; border-top: gray 1px solid;
  16. border-left: gray 1px solid; border-bottom: gray 1px solid;
  17. }
  18. #UpdatePanel1, #UpdatePanel2 {
  19. width:200px; height:200px; position: relative;
  20. float: left; margin-left: 10px; margin-top: 10px;
  21. }
  22. #UpdateProgress1 {
  23. width: 400px; background-color: #FFC080;
  24. bottom: 0%; left: 0px; position: absolute;
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <form id="form1" runat="server">
  30. <div>
  31. <asp:ScriptManager ID="ScriptManager1" runat="server" />
  32. <script type="text/javascript">
  33. var prm = Sys.WebForms.PageRequestManager.getInstance();
  34. prm.add_initializeRequest(InitializeRequest);
  35. function InitializeRequest(sender, args) {
  36. if (prm.get_isInAsyncPostBack())
  37. {
  38. args.set_cancel(true);
  39. }
  40. }
  41. function AbortPostBack() {
  42. if (prm.get_isInAsyncPostBack()) {
  43. prm.abortPostBack();
  44. }
  45. }
  46. </script>
  47. <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
  48. <ContentTemplate>
  49. <%=DateTime.Now.ToString() %> <br />
  50. <asp:Button ID="Button1" runat="server" Text="Refresh Panel" OnClick="Button_Click" />
  51. <br />
  52. Clicking the button while an asynchronous postback is in progress will
  53. cancel the new postback. New postbacks are only allowed if one is not
  54. already in progress.
  55. </ContentTemplate>
  56. </asp:UpdatePanel>
  57. <asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" runat="server">
  58. <ContentTemplate>
  59. <%=DateTime.Now.ToString() %> <br />
  60. <asp:Button ID="Button2" runat="server" Text="Refresh Panel" OnClick="Button_Click"/>
  61. </ContentTemplate>
  62. </asp:UpdatePanel>
  63. <asp:UpdateProgress ID="UpdateProgress1" runat="server">
  64. <ProgressTemplate>
  65. Update in progress...
  66. <input type="button" value="stop" onclick="AbortPostBack()" />
  67. </ProgressTemplate>
  68. </asp:UpdateProgress>
  69. </div>
  70. </form>
  71. </body>
  72. </html>