Sunday, April 11, 2010

Count page load time in asp.net

Put the following code in the asp.net page for which you want to see the page load time.

 



DateTime startTime = DateTime.Now;

protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
this.loadTimeLabel.Text = (DateTime.Now - startTime).TotalMilliseconds.ToString();
this.serverTimeLabel.Text = DateTime.Now.ToString();
}

No comments:

Post a Comment