Wednesday, June 13, 2012

How to redirect to another page after alert message?


This is common requirement that- after doing some server side functionality we want to show alert message and then redirect to another page.

Here I am showing - How to redirect to another page after alert message?

Here is code-
 

Method 1:
 
Response.Write("<script> alert('Your Message.');window.location='TargetpageURL'; </script>");

Method 2:  If you are using Ajax functionality on that case Response.Write() will not work then you can use this code-

  ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ScriptKey", "alert('Your Message.');window.location='TargetpageURL'; ", true);

Thanks

No comments:

Post a Comment