1

データをプルしてロードするのに時間がかかる非常に大きなページがあります。最初に .aspx ページに移動するとき、表示される前にウィンドウを閉じないように、読み込み中の .png 画像が表示されるようにしたいと思います。asp:UpdateProgress を入れてみましたが、これはページが読み込まれるまで表示されず、ページで何かを行います。ページの残りの部分が読み込まれる前に、最初に読み込み画面を取得するにはどうすればよいですか? 以下は、私が試したもので、うまくいきません。

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="10">
        <ProgressTemplate>
            <div id="updatestatus" class="shadow">
            <asp:Label ID="Label12" runat="server" Text="Loading...">
            </asp:Label>
            <asp:Image ID="Image1"
            runat="server" ImageUrl="~/images/1status.png" />
            </div>
        </ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        <%-- My page loading stuff -->
        </ContentTemplate>
</asp:UpdatePanel>

タイマーもつけてみました。ここで面白くなります。ContentTemplate 内のラベルは、目盛りで正常に表示されます。Content Template 内に配置した GridView はそうではありません。

<asp:ScriptManager ID="ScriptManager1" runat="server" />
    <asp:Image ID="Image1" runat="server" ImageUrl="~/images/1status.png" />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" Visible="false">
        <ContentTemplate>
            <!-- My page loading stuff -->
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:Timer ID="Timer1" runat="server" Interval="600" OnTick="Timer1_Tick"></asp:Timer>


protected void Timer1_Tick(object sender, EventArgs e)
{
 UpdatePanel1.Visible = true;
 Timer1.Enabled = false;
 Image1.Visible = false;
}

updatepanel を完全に取り出して、タイマーで gridview の表示状態を変更するだけでも試しましたが、それでも機能しません。グリッドビューは表示されません。

興味深いのは、次のことを行うボタンをページに配置すると、

protected void ButtonHide_Click(object sender, EventArgs e)
{
        if (GridView1.Visible)
        {
            GridView1.Visible = false;
        }
        else
        {
            GridView1.Visible = true;
        }

}

それをクリックして、GridView を何回でも問題なく表示および非表示にすることができます。タイマーが違うのはなぜですか?

4

1 に答える 1

0

.aspx コードでタイマーを設定しましたが、TimerRefreshオフのままにします。次に、これが PostBack でない場合 (初めて)、ページの読み込みが開始されたときに、 をオンにしTimerRefreshます。すぐにカチカチします。これにより、PostBack となるページのリロードが発生します。これによりUpdateProgress1、表示されます。 PageLoad()これは PostBack であるため、何もしません。 TimerRefresh_Tick(object sender, Eventargs e)これはタイマーの刻みからトリガーされたためです。これにより、タイマーの再実行がオフになり、ページにデータが読み込まれます。完了するとすぐUpdateProgress1に消えます。

Page_Load()

if (!IsPostBack)
{
 TimerRefresh.Enabled = true;
}

TimerRefresh_Tick(object sender, EventArgs e)

TimerRefresh.Enabled = false;
codeToLoadDate();

.aspx

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="10">
    <ProgressTemplate>
        <div id="updatestatus" class="shadow">
        <asp:Label ID="Label12" runat="server" Text="Loading...">
        </asp:Label>
        <asp:Image ID="Image1"
        runat="server" ImageUrl="~/images/1status.png" />
        </div>
    </ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Timer ID="TimerRefresh" runat="server" Interval="100" 
         ontick="TimerRefresh_Tick" Enabled="False">
    <%-- My page loading stuff - controls that would hold data -->
    </ContentTemplate>
</asp:UpdatePanel>
于 2014-03-28T16:09:51.683 に答える