I have a button and textbox on my page aspx and on button click event I am displaying alert message.
Now when I run website and click on button it display message but after that when I press F5 (Refresh) it again display message. So my question how to remove message when I click F5.
Below is my code for button click:
protected void btnExport_Click(object sender, EventArgs e) { DisplayMessage("There is no data to Export.", this); }
and
public void DisplayMessage(String strMessage, Control name) { string script = "<script language='javascript'>alert('" + strMessage + "');</script>"; ScriptManager.RegisterStartupScript(name, name.GetType(), "JSCR", script, false); }
Advertisement
Answer
Change your script as follows
string script = "alert('hello');window.location.href='Default.aspx'";
where i assumed Default.aspx
is your page