I have a page with two text-boxes and a button. After the user fills the text-boxes and clicks on the button, the data of text-boxes are written to the database. Then a message box should be shown to user expressing that the data was written in the database. When the user clicks the OK button on the message box, another asp.net page is shown. I have added the following code in button click and the page redirect without showing the message box.
protected void ButtonSubmit_Click(object sender, EventArgs e)
{
...
...
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "The data was written!" + "');", true);
Response.Redirect("Login.aspx");
}
How can I show a message box on a web page before redirect to another web page in asp.net?
You'll want to do the redirect on the client side after the alert:
protected void ButtonSubmit_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('The data was written!'); window.location.replace('Login.aspx');", true);
}