locked
How to stop back button of latest IE and Chrome browsers from reloading page RRS feed

  • Question

  • User1820622718 posted

    Hello,

    I have a site I am working on that has options that a user will be able to select from.  There are 3 different radio button groups.  So I make my selections and then click submit so the data file is being generated.  After it finishes I want to be able to go back to the previous page and have my selections still displayed.   With firefox 56.0.1 it works correctly and I am able to press the back arrow and I see my selections and I am able to change them and re-submit.  With IE 11 and Chrome 61 when I press the back button the previous page looks like it has been reloaded and all the default options are selected.

    I did try Response.Cache.SetCacheability(HttpCacheability.Public); within my page_load of the page with the radio button groups but that didn't do anything.

    Thank you for any help you can give me.

    Thursday, October 26, 2017 4:29 PM

Answers

  • User347430248 posted

    Hi Jerry8989,

    we cannot stop back button from reloading the page.

    we cannot change anything in IE and Chrome.

    but here, if we see your requirement then you are trying to preserving the value of the web page.

    so you can try to use session and try to store the selected values in session before redirecting to any other page.

    then when you press back button and when page gets reloads , you can try to reassign that session values to your controls.

    by this way you can able to use your last time selected values.

    example:

     protected void Page_Load(object sender, EventArgs e)
            {
                if (IsPostBack)
    
                {
                    if (Session["rdbtn1"]!=null)
                    {
                        RadioButtonList1.Text = Session["rdbtn1"].ToString();
                        RadioButtonList2.Text = Session["rdbtn2"].ToString();
                    }
                   
                }
               
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
                Session["rdbtn1"] = RadioButtonList1.Text;
                Session["rdbtn2"] = RadioButtonList2.Text;
                Response.Redirect("About.aspx");
            }

    Output:

    Regards

    Deepak

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 27, 2017 2:39 AM

All replies

  • User347430248 posted

    Hi Jerry8989,

    we cannot stop back button from reloading the page.

    we cannot change anything in IE and Chrome.

    but here, if we see your requirement then you are trying to preserving the value of the web page.

    so you can try to use session and try to store the selected values in session before redirecting to any other page.

    then when you press back button and when page gets reloads , you can try to reassign that session values to your controls.

    by this way you can able to use your last time selected values.

    example:

     protected void Page_Load(object sender, EventArgs e)
            {
                if (IsPostBack)
    
                {
                    if (Session["rdbtn1"]!=null)
                    {
                        RadioButtonList1.Text = Session["rdbtn1"].ToString();
                        RadioButtonList2.Text = Session["rdbtn2"].ToString();
                    }
                   
                }
               
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
                Session["rdbtn1"] = RadioButtonList1.Text;
                Session["rdbtn2"] = RadioButtonList2.Text;
                Response.Redirect("About.aspx");
            }

    Output:

    Regards

    Deepak

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 27, 2017 2:39 AM
  • User1820622718 posted

    Hi Deepak,

    Thank you for your response.  I implemented it, but when I press back only 2 of the 3 radio button lists have the correct value selected. 

    No event fires when I press back so I'm not sure how to set the radio list button text value to the session value. 

    The control that is giving me problems is loaded based on other criteria so it isn't hard coded like the other 2.  Could that be an issue?

    My users have to already be logged in to get to this point so I have other session variables, but that shouldn't be an issue.  I'm using IE 11 for my current testing.

    Thank you again.  I think this is the correct approach once I get this last part figured out.

    Friday, October 27, 2017 1:18 PM
  • User1820622718 posted

    Hi Jerry8989,

    we cannot stop back button from reloading the page.

    we cannot change anything in IE and Chrome.

    but here, if we see your requirement then you are trying to preserving the value of the web page.

    so you can try to use session and try to store the selected values in session before redirecting to any other page.

    then when you press back button and when page gets reloads , you can try to reassign that session values to your controls.

    by this way you can able to use your last time selected values.

    example:

     protected void Page_Load(object sender, EventArgs e)
            {
                if (IsPostBack)
    
                {
                    if (Session["rdbtn1"]!=null)
                    {
                        RadioButtonList1.Text = Session["rdbtn1"].ToString();
                        RadioButtonList2.Text = Session["rdbtn2"].ToString();
                    }
                   
                }
               
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
                Session["rdbtn1"] = RadioButtonList1.Text;
                Session["rdbtn2"] = RadioButtonList2.Text;
                Response.Redirect("About.aspx");
            }

    Output:

    Regards

    Deepak

    Hi Deepak,

    I used your approach and it worked great for Chrome, but I'm still having issues with IE.   The almost all my users use Firefox and Chrome so at least I have it working for them at this point.

    Thank you

    Friday, October 27, 2017 8:15 PM