locked
Timer affects all UpdateProgress RRS feed

  • Question

  • User-2050663300 posted

    I am using 2 UpdateProgress in one web form.

    Now, the problem is that because of timer, when it fires tick event, both UpdateProgress starts showing progress.

    How to prevent this problem ???

    Wednesday, September 11, 2013 1:28 AM

Answers

  • User-417640953 posted

    I am already using AssociatedUpdatePanelID... let me check out another option...

    Hi jeeten,

    Thanks for posting in asp.net forum.

    According to your description, I understand you want another solution to show only one UpdateProgress when the Timer tick.

    For this issue, I suggest you use the javascript to complete it. Below is a demo for this issue.

    Aspx:

    <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server"> 
            </asp:ScriptManager>
            <script>  
                Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
                Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
                var html,nodeId;
                function BeginRequestHandler(sender, args)
                {
                    nodeId = args.get_postBackElement().id;
                    //if timer1 cause callback, then hide UpdateProgress2
                    if (nodeId == "Timer1")
                    {
                        html = document.getElementById("UpdateProgress2").innerHTML;
                        document.getElementById("UpdateProgress2").innerHTML = "";
                    }
                }
                function endRequestHandler(sender, args)
                {
                    if (nodeId == "Timer1") {
                        document.getElementById("UpdateProgress2").innerHTML = html;
                       // alert(document.getElementById("UpdateProgress2").innerHTML);
                    }
    
                }  
            </script>
            
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    Hello1
                    <asp:Timer ID="Timer1" runat="server" Interval="2000" OnTick="Timer1_Tick" ></asp:Timer>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
                </Triggers>
            </asp:UpdatePanel>
            <asp:UpdateProgress ID="UpdateProgress1" runat="server" >
                <ProgressTemplate>
                    UpdateProgress1
                </ProgressTemplate>
            </asp:UpdateProgress> 
            <asp:UpdateProgress ID="UpdateProgress2" runat="server"  >
                <ProgressTemplate>
                    UpdateProgress2
                </ProgressTemplate>
            </asp:UpdateProgress>
        
    </div>
    

    Code behind:

    protected void Timer1_Tick(object sender, EventArgs e)
            {
     
                System.Threading.Thread.Sleep(2000);
              
            }
    

    It works fine in my workaround, please try it. Thanks.

     

    Best Regards!


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 12, 2013 7:16 AM

All replies

  • User527778624 posted

    Hi,

    try using AssociatedUpdatePanelID property of UpdateProgress.

    or You may try hiding one of them by JS, check this site for more details:

    http://msdn.microsoft.com/en-us/library/bb386518%28v=vs.100%29.aspx

    Wednesday, September 11, 2013 1:44 AM
  • User-2050663300 posted

    Hi,

    try using AssociatedUpdatePanelID property of UpdateProgress.

    or You may try hiding one of them by JS, check this site for more details:

    http://msdn.microsoft.com/en-us/library/bb386518%28v=vs.100%29.aspx

    I am already using AssociatedUpdatePanelID... let me check out another option...

    Wednesday, September 11, 2013 1:47 AM
  • User-417640953 posted

    I am already using AssociatedUpdatePanelID... let me check out another option...

    Hi jeeten,

    Thanks for posting in asp.net forum.

    According to your description, I understand you want another solution to show only one UpdateProgress when the Timer tick.

    For this issue, I suggest you use the javascript to complete it. Below is a demo for this issue.

    Aspx:

    <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server"> 
            </asp:ScriptManager>
            <script>  
                Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
                Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
                var html,nodeId;
                function BeginRequestHandler(sender, args)
                {
                    nodeId = args.get_postBackElement().id;
                    //if timer1 cause callback, then hide UpdateProgress2
                    if (nodeId == "Timer1")
                    {
                        html = document.getElementById("UpdateProgress2").innerHTML;
                        document.getElementById("UpdateProgress2").innerHTML = "";
                    }
                }
                function endRequestHandler(sender, args)
                {
                    if (nodeId == "Timer1") {
                        document.getElementById("UpdateProgress2").innerHTML = html;
                       // alert(document.getElementById("UpdateProgress2").innerHTML);
                    }
    
                }  
            </script>
            
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    Hello1
                    <asp:Timer ID="Timer1" runat="server" Interval="2000" OnTick="Timer1_Tick" ></asp:Timer>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
                </Triggers>
            </asp:UpdatePanel>
            <asp:UpdateProgress ID="UpdateProgress1" runat="server" >
                <ProgressTemplate>
                    UpdateProgress1
                </ProgressTemplate>
            </asp:UpdateProgress> 
            <asp:UpdateProgress ID="UpdateProgress2" runat="server"  >
                <ProgressTemplate>
                    UpdateProgress2
                </ProgressTemplate>
            </asp:UpdateProgress>
        
    </div>
    

    Code behind:

    protected void Timer1_Tick(object sender, EventArgs e)
            {
     
                System.Threading.Thread.Sleep(2000);
              
            }
    

    It works fine in my workaround, please try it. Thanks.

     

    Best Regards!


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 12, 2013 7:16 AM