代码之家  ›  专栏  ›  技术社区  ›  edosoft

ASP。NET 3.5:在Page_Load()期间显示更新进度

  •  2
  • edosoft  · 技术社区  · 17 年前

    <asp:Content ID="Content2" ContentPlaceHolderID="PageContentPlaceHolder" runat="server">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                the page here..
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="100">
            <ProgressTemplate>
                <div>
                    <asp:Image ID="AjaxImage" runat="server" ImageUrl="Ajax.gif" />
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
    </asp:Content>
    

    protected void Page_Load(object sender, EventArgs e)
    {            
      if (!IsPostBack)            
      {
        LongRunningProcess();                
      }
    }
    

    6 回复  |  直到 17 年前
        1
  •  2
  •   JBrooks    17 年前
    1. 在“设计”视图中双击Timer对象以创建_tick处理程序。
    2. protected void My_Timer_Tick(object sender, EventArgs e)
      {
          My_Timer_Name.Enabled = false;
          My_Page_Load_Function(); // Function created in step 1 above)
      }
      
      protected void My_Page_Load_Function()
      {
          System.Threading.Thread.Sleep(5000); // A delay to simulate doing something.
          lblMyLabel.Text = "Done!";  // Write output to page. 
      } 
      
        2
  •  3
  •   fthiella    13 年前

    在javascript pageLoad()函数中,使用Ajax的PageMethods回调页面。

       function pageLoad(sender, args) {
                    PageMethods.getVersions(LoadVersionsCallback);
        }
    

       [System.Web.Services.WebMethod]
        public static string getVersions()
        {
          StringBuilder sb = new StringBuilder();
           ... etc.
          return sb.ToString();
    
        }
    

       function LoadVersionsCallback(result) {
        // do something with the results - I load a dropdown list box.
    
       ...etc. 
        // here is where you hide your div holding the Ajax.gif  
    
       }
    

        3
  •  2
  •   bytebender    17 年前

    我会在页面上放置一个Ajax计时器,并将其设置为不到一秒。..它只会运行一次,在第一次勾选后,您需要禁用它,否则它将再次启动。(你不想多次启动你的长期运行过程……)

        4
  •  1
  •   user291100    16 年前

                <asp:Panel ID="DetailPanel" runat="server" CssClass="submitBox detailPanel">
                    <asp:Table ID="Table1" runat="server" Width="100%">
                        <asp:TableHeaderRow ID="TableHeaderRow10" runat="server">
                            <asp:TableCell ID="TableHeaderCell" runat="server"
                                Font-Bold="true" HorizontalAlign="Center">
                            Title Text
                            </asp:TableCell>
                        </asp:TableHeaderRow>
                        <asp:TableRow>
                            <asp:TableCell HorizontalAlign="Center">
                                <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/animated_progress.gif" />
                            </asp:TableCell>
                        </asp:TableRow>
                    </asp:Table>
                    <div class="iframeOverlay">
                        <iframe id="IframeDetail" runat="server" style="width: 100%; height: 100%;" />
                    </div>
                </asp:Panel>
    

        5
  •  0
  •   user1671697    11 年前

    <script>
     $(document).ready(function() {
     $('#<%= UpdateProgress1.ClientID %>').show(); 
     });
    </script>
    
        6
  •  0
  •   Nathan Tuggy TonyLuigiC    11 年前
    <script>  $(document).ready(function() {  $('#<%=
    UpdateProgress1.ClientID %>').show();   }); </script>