Two updatepannels on same page, dont refresh indepedanty

18 Views Asked by At

I have two updatepannels with Lablel and a button in each.

when I click on button, it send request and wait for 5 sec followed by update lable with time.

when I click btn1, wait for 5 sec, code is working fine. when I click btn2, wait for 5 sec, code is working fine. but when I click on btn1, and without waiting for response (before 5 sec),I click on btn2, only second updatepannel lable- lbl2 is updating.

is there any way that server should handle both requests independently ?

here is my code:

<asp:UpdatePanel runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional" >
        <ContentTemplate> 
            <asp:Label Text="text" runat="server" ID="lbl1" />
            <asp:Button Text="ok1" runat="server" ID="btn1" OnClick="btn1_Click"      />
        </ContentTemplate>
        <Triggers >
            <asp:AsyncPostBackTrigger ControlID="btn1" EventName="Click" />  
        </Triggers>   
    </asp:UpdatePanel>

    <asp:UpdatePanel runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
        <ContentTemplate> 
            <asp:Label Text="text" runat="server" ID="lbl2" />
            <asp:Button Text="ok2" runat="server" ID="btn2" OnClick="btn2_Click"       />
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btn2" EventName="Click" />  
        </Triggers>    
    </asp:UpdatePanel>

======================================================================================

protected void btn1_Click(object sender, EventArgs e)
        {
            Thread.Sleep(5000);
            lbl1.Text = "Done2 "+ DateTime.Now.ToString();
        }

 
        protected void btn2_Click(object sender, EventArgs e)
        {
            Thread.Sleep(5000);
            lbl2.Text = "Done4 " + DateTime.Now.ToString();
        }

as per my requirement, when I click on btn1, followed by click on btn2 after 2 sec,

lbl1 should update after 3 sec and lbl2 should update after 5 sec.

0

There are 0 best solutions below