using System; 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.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.Globalization; using System.Drawing.Drawing2D; using System.Runtime.InteropServices; public partial class _Default : System.Web.UI.Page { Stopwatch sw=new Stopwatch (); bool pas = false; protected void Page_Load(object sender, EventArgs e) { sw.Start(); } protected void Timer1_Tick(object sender, EventArgs e) { if (sw.IsRunning) { TimeSpan objTimeSpan = TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds); Label1.Text = String.Format(CultureInfo.CurrentCulture, "{0:00}:{1:00}:{2:00}.{3:00}", objTimeSpan.Hours, objTimeSpan.Minutes, objTimeSpan.Seconds, objTimeSpan.Milliseconds / 10); if (pas) { pas = false; } } } protected void Button1_Click(object sender, EventArgs e) { sw.Start(); } protected void Button2_Click(object sender, EventArgs e) { sw.Stop(); } protected void Button3_Click1(object sender, EventArgs e) { Label1.Text = "00:00:00.00"; sw.Reset(); } }
sw.ElapsedMilliseconds
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)