我对计时器感到不安。处理它的时间。 [英] i am troubling with timer. to handle its time.

查看:54
本文介绍了我对计时器感到不安。处理它的时间。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个定时器控制的问题,当我连续点击下一个按钮它停止。当我停下来点击下一个按钮它再次启动...我希望当我连续点击下一个按钮时,该计时器不应该停止。请帮助我紧急

--------- ---------

我的aspx代码是:



i have a problem with timer control when i click on next button continuously it stop . when i stop to click next button it again start...i want that timer should not stop when i click on next button continuously.please help me its urgent
------------------
My aspx code is:

<asp:Content ID="Content1" ContentPlaceHolderID="cphmain" runat="Server">

    <div id="contents">
        <div id="maindiv" style="padding-removed 100px; width:850px;">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            
            <table>
            <tr>
            <td>
            <input type="button" value="Start count!" onclick="doTimer()"/></td>
            <td>
                <input id="txt1" type="text" />
                <div id="txt"></div>
                <asp:Label ID="Label1" runat="server" Text="Label"> 
                
</td>
<td>
<input type="button" value="Stop count!" onclick="stopCount()"/>
            </td>
            </tr>
            </table>
                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                <contenttemplate>
                <div>
                <asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" Interval="500">
                
                <asp:Label ID="lbltimer" runat="server" Text="Label">
            </div>
            </contenttemplate>
                
                <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                <contenttemplate>
            <asp:Panel ID="panel1" runat="server">
            <table>
            <tr>
            <td style="width:auto;">
                <asp:Label ID="lblquestun" runat="server" Text="label"></td>
                
            </tr>
            
            
            </table>
            <table>
            <tr>
            <td>
                <asp:RadioButton ID="radA" runat="server" GroupName="grp1" Text="rad1"/></td>
            <td>
                <asp:RadioButton ID="radB" runat="server" GroupName="grp1" Text="rd2"/></td>
            </tr>
            <tr>
            <td>
                <asp:RadioButton ID="radC" runat="server" GroupName="grp1" Text="rd3"/></td>
            <td>
                <asp:RadioButton ID="radD" runat="server" GroupName="grp1" Text="rd4"/></td>
            </tr>
            <tr>
            <td colspan="2" align="right">
                </td>
                
            </tr>
            </table>
                <table>
                <tr>
                <td><asp:Button ID="Button1" runat="server" Text="Next" GroupName="grp1" 

                    onclick="Button1_Click1"/></td>
                </tr>
                </table>
                
            
            </contenttemplate>
            
        </div>
    </div>



--------- ----

我的cs代码是:






-------------
My cs code is:


static DataTable dt = new DataTable();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            csQuestun obj = new csQuestun();
            dt = obj.GetQuestun();
            string str;
            str = dt.Rows[0][0].ToString();
            lblquestun.Text = "1: " + str;
            radA.Text = dt.Rows[0][1].ToString();
            radB.Text = dt.Rows[0][2].ToString();
            radC.Text = dt.Rows[0][3].ToString();
            radD.Text = dt.Rows[0][4].ToString();
            lbltimer.Text = DateTime.Now.ToLongTimeString();  
        }
    }
 static int count = 1;
    static int NOcount = 2;
    protected void Button1_Click1(object sender, EventArgs e)
    {
        try
        {
            string str = null;

            if (count < dt.Rows.Count)
            {
                str = dt.Rows[count][0].ToString();
                lblquestun.Text = NOcount.ToString() + ": " + str;
                radA.Text = dt.Rows[count][1].ToString();
                radB.Text = dt.Rows[count][2].ToString();
                radC.Text = dt.Rows[count][3].ToString();
                radD.Text = dt.Rows[count][4].ToString();
                count++;
                NOcount++;
            }
            else
            {
                lblquestun.Text = "End";
                count = 1;
            }
            //WebControl cnt = (WebControl)Page.FindControl("txt");
            //Label1.Text = cnt.ToString();
            
        }
        catch (Exception)
        { }
    }
protected void Timer1_Tick(object sender, EventArgs e)
    {
        lbltimer.Text = DateTime.Now.ToString("mm:ss");
    }

--------------------

thaxxx for advance

--------------------
thaxxx for advance

推荐答案

谈到带有计时器的Asp和网页,我们说的是java脚本。不是吗?!如果您必须知道浏览器可能会在不同情况下停止java脚本。除了更改应用程序逻辑之外,你无法阻止它。
Speaking about Asp and webpages with timer mean we are talking about java script. Isn''t it?! If you you must to know that browser may stop java script in different cases. There is no way you can prevent it except changing your application logic.


说到带有计时器的Asp和网页意味着你在谈论java脚本。不是吗?!如果是这样,您必须知道浏览器可能会在不同情况下停止java脚本。除了更改应用程序逻辑之外,您无法阻止它。
Speaking about Asp and webpages with timer mean you are talking about java script. Isn''t it?! If so, you must to know that browser may stop java script in different cases. There is no way you can prevent it except changing your application logic.


这篇关于我对计时器感到不安。处理它的时间。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆