加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 无法通过计时器显示分钟

发布时间:2020-12-16 01:50:19 所属栏目:百科 来源:网络整理
导读:我想在标签上显示时间.我的代码是: 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:Ti
我想在标签上显示时间.我的代码是:

<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>

并在aspx页面

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");
    }

它工作正常,但我想显示分钟而不是秒.有没有办法做到这一点?谢谢.

解决方法

将您的间隔更改为60000,这应该代表一分钟.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读