0

誰かがこれを解決する方法を説明できますか?

2 つの更新パネル、2 つの進行状況コントロール、2 つのコマンド ボタン。

最初のボタンをクリックすると、最初の非同期更新の進行状況が表示されます。2 番目のコマンド ボタンをクリックすると、最初の非同期操作がまだ進行中の場合、最初の進行状況バーが消えます。同時に 2 つの進行状況コントロールを表示するにはどうすればよいですか。

    <html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>UpdateProgress Tutorial</title>
    <style type="text/css">
    #UpdatePanel1, #UpdatePanel2 { 
      width:300px; height:100px;
     }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <fieldset>
                <legend>UpdatePanel1</legend>
                <asp:Label ID="Label1" runat="server" Text="Panel initially rendered."></asp:Label>
                <br />
                <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
                <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
                    <ProgressTemplate>
                        Panel1 updating...
                    </ProgressTemplate>
                </asp:UpdateProgress>
                </fieldset>
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>
                <fieldset>
                <legend>UpdatePanel2</legend>
                <asp:Label ID="Label2" runat="server" Text="Panel initially rendered."></asp:Label>
                <br />
                <asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
                <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel2">
                    <ProgressTemplate>
                        Panel2 updating....
                    </ProgressTemplate>
                </asp:UpdateProgress>
                </fieldset>
            </ContentTemplate>
        </asp:UpdatePanel>

    </div>
    </form>
</body>
</html>

コード

    protected void Button1_Click(object sender, EventArgs e)
{
    // Introducing delay for demonstration.
    System.Threading.Thread.Sleep(10000);
    Label1.Text = "Page refreshed at " +
        DateTime.Now.ToString();
}

protected void Button2_Click(object sender, EventArgs e)
{
    // Introducing delay for demonstration.
    System.Threading.Thread.Sleep(15000);
    Label2.Text = "Page refreshed at " +
        DateTime.Now.ToString();

}
4

2 に答える 2

0

In general web works on Request-Response basis. When page send Request it should wait for Response. If page resends[or sends new] Request old Response will be ignored and will wait for Response for new Request.

To avoid this in Ajax queues requests and sends once a reponse has been recieved. [or in other way you can say on page works as single thread]

In your case first Progress bar should not go away even behind the seen it waits for response. this can be fixed using some javascript but there isn't any off the box support.

Or you can use Iframes to truly send simulteneous multiple requests.

于 2013-04-12T14:49:05.333 に答える
0

おそらく必要なのは、更新パネルを条件付きで更新するように構成することです: UpdateMode = "Conditional"

このリンクを確認してください: http://msdn.microsoft.com/es-mx/library/system.web.ui.updatepanel.updatemode.aspx

于 2013-02-07T18:07:49.890 に答える