Submit, Show Results, Hold 3 Seconds and Redirect

I have a form in which users can enter data, and the behavior I'm looking for is after sending code that is written to the database and returns a success response to the page. This code is currently working. The next element that I would like to happen is redirected after a successful message, but I would like to postpone it for 2 or 3 seconds so that the user can see the success message before the redirection.

Behavior: Send → Show success message → 3 seconds delay → Redirect

I am currently developing this in VB; however, I'm fine with examples in VB or C #. This is a traditional web form.

+4
source share
3 answers

I like this approach, although some of the ones already proposed are very good:

protected void Button1_Click(object sender, EventArgs e) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "success", "alert('Submitted Successfully.'); setInterval(function(){location.href='http://www.google.com';},3000);", true); } 

Good luck

+5
source

You can use the Thread.Sleep () method. Just add this before Response.Redirect ie

 System.Threading.Thread.Sleep(3000); Response.Redirect("MyURL"); 

Alternatively, you can add a delay in the response header, like this

 Response.AddHeader "REFRESH","3;URL=MyURL" 

The number indicated above is the delay value in seconds.

+5
source

You can use html meta refresh tag

Just place the next cod in the chapter section of your page containing a success message.

 <meta http-equiv="refresh" content="3;URL='http://nextpageurlaftersuccess.com/'"> 
+2
source

All Articles