Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Submit, Show Results, delay 3 seconds and redirect

I've got a form where users can input data and the behavior that I'm looking for is after the submit, the code behind writes to a database and returns a response of success to the page. I currently have this code working. The next item that I'd like to have happen is redirect after the successful message but I'd like to delay for 2 or 3 seconds allowing the user to see the success message before redirecting.

Behavior: Submit -> Show Success Message -> Delay 3 seconds -> Redirect

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

like image 467
Ryan Schlagel Avatar asked Dec 21 '22 16:12

Ryan Schlagel


1 Answers

I like this approach, although some of the 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!

like image 79
Hanlet Escaño Avatar answered Dec 30 '22 11:12

Hanlet Escaño