How to redirect to another page after alert message in c#?

There is some situation where we want to show alert message and confiration
message before redirecting to another page.

Method 1

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

Method 2

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

Method 3

HTMLHelper.jsAlertAndRedirect(this, "This is an alert.", ResolveUrl("~/Default.aspx"));

Method 4

string  strScript = "<script>"+"alert('your message.');";
                strScript += "window.location='test.aspx';";
                strScript += "</script>";
        Page.ClientScript.RegisterStartupScript(this.GetType(), "Startup", strScript);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s