Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Ajax
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>
-------------
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
Posted 16-Jan-13 22:41pm
Edited 16-Jan-13 22:53pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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

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

  Print Answers RSS
0 OriginalGriff 365
1 Sergey Alexandrovich Kryukov 334
2 CPallini 275
3 DamithSL 230
4 Maciej Los 215
0 OriginalGriff 5,455
1 DamithSL 4,457
2 Maciej Los 3,885
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,115


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 20 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100