locked
Show Updates on Progress RRS feed

  • Question

  • User-1170096362 posted

    Hi,

    I would like to show more information in my UpdatePanel. Instead of showing a simple "Please wait..." message, I would like to show which step it is currently at. Please refer to the sample code below.

    I cannot seem to increment the step on the Tick event of the Timer control.

    What is wrong?


    Thanks,
    ywb

    <%@ Page Language="C#" AutoEventWireup="true" %>

    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Test Timer</title>


        <script runat="server">

            private int stepNumber;

            protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) stepNumber = 1; }

            protected void Timer1_Tick(object sender, EventArgs e)
            {
                switch (stepNumber)
                {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                        TextBox1.Text = "At step " + stepNumber.ToString();
                        System.Threading.Thread.Sleep(stepNumber * 1000);
                        break;
                    default:
                        Timer1.Enabled = false;
                        break;
                }
                TextBox1.Text = "Timer Tick " + stepNumber.ToString();
            }
        </script>


    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:ScriptManager ID="Scriptmanager1" runat="server"></asp:ScriptManager>

                <asp:Timer ID="Timer1" runat="server" Interval="3000" OnTick="Timer1_Tick"></asp:Timer>

                <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                        <%=DateTime.Now.ToString() %>
                    </ContentTemplate>
                </asp:UpdatePanel>

                <asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="0">
                    <ProgressTemplate>
                        Updating...
                    </ProgressTemplate>
                </asp:UpdateProgress>

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

    Tuesday, February 4, 2014 7:16 PM

Answers

All replies

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 4, 2014 10:52 PM
  • User1777983149 posted

    <asp:UpdatePanel ID="UpdatePanel3" runat="server">

    <ContentTemplate>
    <div style="text-align: center;">
    <asp:UpdateProgress ID="UpdateProgress12" runat="server" AssociatedUpdatePanelID="UpdatePanel3"
    DynamicLayout="true">
    <ProgressTemplate>
    <div class="loaderOverlay1">
    </div>
    <img src="images/loader.gif" alt="" />
    </ProgressTemplate>
    </asp:UpdateProgress>
    </div>
    <div>

    </ContentTemplate>

    </asp:UpdatePanel >

    Wednesday, February 5, 2014 2:18 AM
  • User-1170096362 posted

    Thank you, Chetan. That's what I needed!

    Thursday, February 6, 2014 4:55 PM