Monday, August 17, 2009

How to do a Page PostBack With a Delay

Here's a simple way to delay a Page PostBack.

Add the following code in the Page_Load event:

C#


protected void Page_Load(object sender, EventArgs e)

{

TimeSpan ts = new TimeSpan(0, 0, 0, 5);

System.Threading.Thread.Sleep(ts);

}



VB.NET


Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

Dim ts As New TimeSpan(0, 0, 0, 5)

System.Threading.Thread.Sleep(ts)

End Sub




Note: Avoid using this approach too much in a Production environment.

No comments:

Post a Comment