I have a simple asp.net WebForms app with two forms: Main.aspx and Card.aspx. In the Card form I have save button which has the following click event:
protected void buttonSave_Click(object sender, EventArgs e)
{
if (canSave)
{
string script = String.Format("alert(\"{0}\");", "Successfully saved");
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", script, true);
Save();
Response.Redirect("~/Main.aspx");
}
}
So, it should show an alert, save data (Save() method) and redirect to the Main form. Eventhough, it saves data and redirects to the page, it doesn't show an alert. The code that should show an alert works on the page load event but not on the button click event. What is the reason?