Click here to Skip to main content
15,896,730 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.NET
<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>

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


C#
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
Posted
Updated 16-Jan-13 21:53pm
v2

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.
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900