locked
div visibility RRS feed

  • Question

  • User-797751191 posted

    Hi

       i have below code . When it redirects to Form2.aspx and when i click browser back option div1 is in visible mode . It should be false.

    If i don't redirect to form2 page ( i comment response.redirect) then div1 is not visible it works fine. 

    protected void ddl_Option_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddl_Option.SelectedValue == "1")
            {
                div1.visible= false;
                Response.Redirect("Form2.aspx",false);
            }
            
        }

    Thanks

    Friday, July 12, 2019 11:02 AM

All replies

  • User-1038772411 posted

    Hi, jsshivalik

    as per your question not cleared how this happen because we can't see your all code here.

    But as per understanding you need to set :

    div1.visible= true;

    In page load event which you go back after press browser back button. hope this one missing from your side.

    Thanks.

    Friday, July 12, 2019 12:17 PM
  • User753101303 posted

    Hi,

    Response.Redirect stops sending back content for the current page and instead ask the browser to go to another page.

    Maybe hiding this using JavaScript but it seems a fragile approach. Depending on what exactly you want to prevent it seems to me you should have better option than that.

    The user shouldn't be able to change his mind at all ??? (even if starting new on the previous page ???)

    Friday, July 12, 2019 12:19 PM
  • User-797751191 posted

    Hi

      Since i have div1.visible = false before redirect div1 should have visible false , but when i click on back button of browser from form1.aspx div1 is still visible.

    That's my point. When i comment redirect then div1 is not showing up & that is correct. 

    Thanks

    Saturday, July 13, 2019 1:38 PM
  • User409696431 posted

    "Since i have div1.visible = false before redirect div1 should have visible false ,"

    No, you are setting div1.visible = false on the server, in code behind, then you do a redirect to a different page. That visible=false never gets sent down to the browser, only the different page does.  (It works if you comment out the redirect because you are still on the same page and the change is sent down to the browser.)  So a back button doesn't have a cached version of the page with the div not visible, only visible, and if you have nocache set, the page runs again, and the div is visible as it would be when the page is first loaded.

    You need a new approach.

    Sunday, July 14, 2019 6:43 PM