Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Show Updates on Progress

$
0
0

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>


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>