Stopwatch Timer in Asp.Net
<p>I wanna diplay a Stopwatch timer ...using Asp.Net C#...</p>

<p>I reffer many threads  and searched in google also...
But cant find proper code or solution..
Most of the solutions i found were very hard to implemnt and some of didnt worked...</p>

<p>I want to create stopwatch like below Image..</p>

<p><img src="http://i.stack.imgur.com/t65tk.png" alt="enter image description here"></p>

<p>In this by clicking on start button in starts the watch from 00.00 AND format is HH.MM.</p>

<p>and change the text of Button to Stop.
And by click on that again it Stops the watch..
And Then Save that time in database and also display in given TextBox....
by click on Reset it resets the time to 00.00..</p>

<p>how can i do these??</p>

<p>I doesn't  have any idea about this..so some code is needed...</p>

<p><strong>OK BELOW IS THE CODE AND IMAGE WHICH I TRIED  IN WEBSITE...</strong></p>

<p><img src="http://i.stack.imgur.com/y5NdO.png" alt="enter image description here"></p>

<pre><code>using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Diagnostics;





public partial class Default5 : System.Web.UI.Page
{
    private Stopwatch sw = new Stopwatch();
        protected void Page_Load(object sender, EventArgs e)
        {


        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            if (Button3.Text == "start")
            {
                Timer1.Enabled = true;
                sw.Start();
                Button3.Text = "stop";

            }
            else
            {
                Timer1.Enabled = false;
                sw.Stop();
                Button3.Text = "start";

                //TextBox1.Text = Label1.Text;
            }

        }
        protected void Timer1_Tick(object sender, EventArgs e)
        {

            int hrs = sw.Elapsed.Hours;
            //int hrs = "1;
            int mins = sw.Elapsed.Minutes;
            int secs = sw.Elapsed.Seconds;

            Label1.Text = hrs + ":";

            if (mins &lt; 10)
               Label1.Text += "0" + mins + ":";
            else
                Label1.Text += mins + ":";

            if (secs &lt; 10)
                Label1.Text += "0" + secs;
            else
                Label1.Text += secs;



        }

}
</code></pre>

<p><strong>AND THE CODE WRITTEN IN PROJECT(WHICH WORKS WELL) IS...</strong></p>

<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private Stopwatch sw = new Stopwatch();

        private void button1_Click(object sender, EventArgs e)
        {
            if (button1.Text == "Start")
            {
                timer1.Enabled = true;
                sw.Start();
                button1.Text = "Stop";

            }
            else
            {
                timer1.Enabled = false;
                sw.Stop();
                button1.Text = "Start";
                textBox1.Text = label1.Text;
            }

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            int hrs = sw.Elapsed.Hours, mins = sw.Elapsed.Minutes, secs = sw.Elapsed.Seconds;

            label1.Text = hrs + ":";

            if(mins &lt;10)
                label1.Text += "0"  + mins + ":";
            else 
                label1.Text += mins + ":";

            if (secs &lt; 10)
                label1.Text += "0" + secs;
            else
                label1.Text += secs;
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }


    }
}
</code></pre>

<p>In both the timer interval is set at 1000</p>

<p>In the website, the time is not increasing. It remains 0:00:00... </p>
