开发者

Update controls in update panel

I use a updatepanel with some controls ,I when click on button, create a sleep. in this time i click on second buton ,buttons handlers execute async successfully.but one of the lables do not update?

i have two lable in update panel ,when btnPostF button click and then btnPostS button, only lable2 to update in update panel and lable2 do not update!开发者_运维知识库!

<body>
    <form id="form1"  runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">

        <asp:UpdatePanel ChildrenAsTriggers="true" ID="UpdatePanel1"  runat="server" >
            <contenttemplate>
                    <asp:Button runat="server" Text="PostBackFirst" ID="btnPostF" 
                        onclick="btnPostF_Click"/> 
                    <asp:Button runat="server" Text="PostBackSecond" ID="btnPostS"
                        onclick="btnPostS_Click"/> 
                    <asp:Button runat="server" Text="AbortPostBack" ID="btnAbort"
                        OnClientClick="Sys.WebForms.PageRequestManager.getInstance().abortPostBack();
                        alert('Postback Cancelled');"/>
                    <asp:Label ID="Label1" runat="server" Text="">            
                    <asp:Label ID="Label2" runat="server" Text="">            
            </contenttemplate>

    </form>
</body>

protected void btnPostF_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(4000);
            Label1.Text = "PostBack 1 Completed";

        }

        protected void btnPostS_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(4000);
            Label2.Text = "PostBack 2 Completed";

        }


If you are doing second postback (by clicking on second button) while client (your browser) is waiting to finish first request. As soon as you click on second button your first request is aborted by client. So you see result Only from your second request.

In your example if you click on second button first and then on first button, you will see values on label1 and not on label2.

Hope this helps.

Ims

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜