I have an application where I will show Modal Popup
on successful insert, update and delete. But after performing this when I move to next page and coming back to previous page on hitting browser back button the Modal Popup
is getting displayed, I don't want to display this pop up on hitting back button. How can I solve this
protected void Page_Load(object sender, EventArgs e)
{
if (Page.PreviousPage==null) {mpeModalPopup.Show(); }
if (Session["Tasks"] == null)
{
Server.Transfer("login.aspx");
}
else
{
string strTasks = Session["Tasks"].ToString();
if (strTasks.Contains("205"))
{
if (!IsPostBack)
{
mpeModalPopUp.Hide();
funPageLoadData();
CheckPopup();
Session["url"] = System.Web.HttpContext.Current.Request.Url.AbsolutePath;
}
}
else
{
ReturnBack();
}
}
}
You dont seem to have handled Page.IsPostBack boolean property on your page_load event.
if (Page.PreviousPage==null) {mpeModalPopup.Show(); }
For opening the popup (after postback) asp.net changes the html or inserts a javascript function to show the modal popup.
The only solution I know of is triggering an ajax postback (with an UpdatePanel) instead of a full postback when you click the button(s). This way the popup is loaded by an ajax call and won't display when you press the backbutton later on.