Q) I had been trying to use javacript to alert some message and after that I do a response.redirect to another page.

But the alert message seems not appearing and it just redirect to another page.

A) use the below code.here we use location.replace

Location.replace

Syntax:
location.replace(URL)

The replace method replaces the current History entry with the specified URL. After calling the replace method, you cannot navigate back to the previous URL using the browser’s Back button.

Usage

string s = “alert(‘Your Profile Is Successfully Updated’);location.replace(‘Client_home.aspx’);”;
Page.ClientScript.RegisterStartupScript(this.GetType(), “sri”, s, true);

Blogged with Flock

Advertisement