我现在是想做一个页面载入,当一个页面上的数据没有加载完毕那么显示一张loading的图片,如果一个页面的数据加载完毕,那么就显示页面。   关键是,怎么判断一个.aspx页面上所有的数据是否加载完毕,我知道怎么去判断iframe中的类容,但不知道怎么去判断一个单独的页面上所有的类容。最好帮我来段代码。越想希望好,才接触asp.net.比较急,麻烦个位大侠、帮小弟看看,谢谢各位了。

解决方案 »

  1.   

    不是用进度条,我直接用了一张图片,我这有判断ifram中的类容是否加载完毕:
    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
    </head>
    <body>
    <form runat="server"><div id="LoadingDiv" style="display:block;width:250px; font-size:13px; background-image:url('img/loading.gif'); background-repeat:no-repeat; height:39px; background-position:center; text-align:center;"></div>
    <div id="LoadingFrmdiv" style="display:none;">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always" ChildrenAsTriggers="true">
            <ContentTemplate>
                <iframe src="http://www.hao123.com" width="500px;" height="900px;" id="ice" onreadystatechange="if(this.readyState=='complete'){ document.getElementById('LoadingDiv').style.display='none';
          document.getElementById('LoadingFrmdiv').style.display='block';}"></iframe> 
            </ContentTemplate>
        </asp:UpdatePanel>
        </div>
       
       </form>
    </body>
    </html>
     
    但怎么去判断单一一个页面,是否加载完毕了?
      

  2.   

    你既然都用到ScriptManager了。还是给个例子你吧
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" ></asp:ScriptManager>
            <div>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
                    <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                    <ProgressTemplate>
                    请稍后.....
                    </ProgressTemplate>
                    </asp:UpdateProgress>
                
                
                </ContentTemplate>
                
                </asp:UpdatePanel>
                </div>
        </form>
    </body>
    </html>
      

  3.   


    <cc1:UpdatePanelAnimationExtender ID="UpdatePanelAnimationExtender1" runat="server" TargetControlID="updatePanel1">
              <Animations>
                        <OnUpdating>
                            <Parallel duration="0">
                                <%-- place the update progress div over the gridview control --%>
                                <ScriptAction Script="onUpdating();" />  
                             </Parallel>
                        </OnUpdating>
                        <OnUpdated>
                            <Parallel duration="0">
                                <%--find the update progress div and place it over the gridview control--%>
                                <ScriptAction Script="onUpdated();" /> 
                            </Parallel> 
                        </OnUpdated>
                    </Animations>
        </cc1:UpdatePanelAnimationExtender>
        <asp:Panel ID="pnlPopup" runat="server"  style="display:none;">
                   
                        Loading, please wait...
                        <img src="images/activity.gif" />
                           
                </asp:Panel> 
    UpdatePanelAnimationExtender 表示在某个特定的面板中数据更新的时候该面板显示出来的动画效果
    脚本如下:
     function onUpdating() {
                  // get the update progress div
                  var pnlPopup = $get('<%= this.pnlPopup.ClientID %>');              //  get the gridview element
                  var gridView = $get('<%= this.GridView1.ClientID %>');              // make it visible
                  pnlPopup.style.display = '';              // get the bounds of both the gridview and the progress div
                  var gridViewBounds = Sys.UI.DomElement.getBounds(gridView);
                  var pnlPopupBounds = Sys.UI.DomElement.getBounds(pnlPopup);              //  center of gridview
                  var x = gridViewBounds.x + Math.round(gridViewBounds.width / 2) - Math.round(pnlPopupBounds.width / 2);
                  var y = gridViewBounds.y + Math.round(gridViewBounds.height / 2) - Math.round(pnlPopupBounds.height / 2);              // set the progress element to this position
                  Sys.UI.DomElement.setLocation(pnlPopup, x, y);
              }          function onUpdated() {
                  // get the update progress div
                  var pnlPopup = $get('<%= this.pnlPopup.ClientID %>');
                  // make it invisible
                  pnlPopup.style.display = 'none';
              }            
                
            </script>
      

  4.   

    需要改动一下,我加载完了是显示的GridView1数据
      

  5.   


    document.onreadystatechange = endLoad;
    function endLoad()
    {
       if (document.readyState=="complete")
       {
          ... ...
       }
    }
      

  6.   

    foren_whb  你好!这个貌似只能判断ifram中的类容加载是否完毕吧
      

  7.   


    你这个里面的控件<cc1:UpdatePanelAnimationExtender ID="UpdatePanelAnimationExtender1" runat="server" TargetControlID="updatePanel1">是什么控件?我怎么都没有找到?
      

  8.   

    现在需求又变了,现在是要判断frameset框架中其中一个frame中的类容是否加载完毕,各位大侠在帮我看看怎么判断啊