hello All,

Good Day to u all.

I m new to .net.

I just want to implement a stopwatch in asp.net.

Can any one help?


Thanks in advance.

possible using Javascript, Ajax Timer Control..

I found solution.
No need of JavaScript

.....................................................................................
DESIGN
.....................................................................................

<div>
	<asp:Timer runat="server" ID="Timer1" Interval="1000" OnTick="Timer1_Tick" Enabled="False" />
	<asp:UpdatePanel runat="server" ID="TimePanel" UpdateMode="Always">
	<Triggers>
		<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
	</Triggers>
	<ContentTemplate>
		<asp:Label ID="lblMinute" runat="server"></asp:Label>
		<asp:Label runat="server" ID="lblTimeSep" Text=" : " />
		<asp:Label runat="server" ID="lblSeconds"/>
	</ContentTemplate>
	</asp:UpdatePanel>
</div>

.....................................................................................
C# CODE
.....................................................................................

static int seconds = 59;
static int minute = 0; // maximum value as ur desire
protected void Timer1_Tick(object sender, EventArgs e)
{
	seconds--;
	if (seconds == 0)
        {
            seconds = 59;
            minute = minute + 1;
        }
        
        if (minute==30) 
        {
           Response.Redirect("ThankYou.aspx");  // event ot handle
        }
        lblMinute.Text = minute.ToString();
        lblSeconds.Text = seconds.ToString();
}

...................................................................................

Thank You.

I found solution.
No need of JavaScript

:D
Its called AJAX (Asynchronous JavaScript and XML).

Hmm can't he just do Interval="1800000" instead of calling it every second.

That every seconds is for displaying...

fair enough.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.