Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to display minute through Timer

Tags:

c#

asp.net

I want to display time in a label. My code is:

<asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:Timer ID="Timer1" runat="server" Interval="3000" OnTick="Timer1_Tick">
                    </asp:Timer>
                    <asp:Label ID="Label1" runat="server" Text="Remaining Time:(Sec)"></asp:Label>
                    <asp:Label ID="Label2" runat="server" Text="100"></asp:Label>
                </ContentTemplate>
            </asp:UpdatePanel>

        </div>

and in aspx page

protected void Timer1_Tick(object sender, EventArgs e)
    {
        Label2.Text = Convert.ToString((Convert.ToInt32(Label2.Text) - 1));
        if (Convert.ToInt32(Label2.Text) == 0)
            Response.Redirect("~/Default2.aspx");
    }

It works fine, but i want to display the minute instead of the second. Is there any method to do this? Thanks.

like image 561
4b0 Avatar asked Feb 23 '26 15:02

4b0


1 Answers

Change your Interval to 60000 which should represent one minute.

like image 112
Matthias Avatar answered Feb 25 '26 03:02

Matthias



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!