default.aspx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. function AbortPostBack() {
  34. var prm = Sys.WebForms.PageRequestManager.getInstance();
  35. if (prm.get_isInAsyncPostBack()) {
  36. prm.abortPostBack();
  37. }
  38. }
  39. </script>
  40. <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
  41. <ContentTemplate>
  42. <%=DateTime.Now.ToString() %> <br />
  43. <asp:Button ID="Button1" runat="server" Text="Refresh Panel" OnClick="Button_Click" />
  44. <br />
  45. To stop the existing
  46. asynchronous postback without starting a new one, click the button
  47. provided in the ProgressTemplate.
  48. </ContentTemplate>
  49. </asp:UpdatePanel>
  50. <asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" runat="server">
  51. <ContentTemplate>
  52. <%=DateTime.Now.ToString() %> <br />
  53. <asp:Button ID="Button2" runat="server" Text="Refresh Panel" OnClick="Button_Click"/>
  54. </ContentTemplate>
  55. </asp:UpdatePanel>
  56. <asp:UpdateProgress ID="UpdateProgress1" runat="server">
  57. <ProgressTemplate>
  58. Update in progress...
  59. <input type="button" value="stop" onclick="AbortPostBack()" />
  60. </ProgressTemplate>
  61. </asp:UpdateProgress>
  62. </div>
  63. </form>
  64. </body>
  65. </html>