I have a button that is visible only for certain item's page. Clicking the button leads to the item's detail page. On hitting the browser's back button, the item page is rendered without the button. And, if I hit refresh then the button appears. How do I render the button as well without refreshing.

Thanks!

有帮助吗?

解决方案

just in case anyone is looking, for the button to be visible some other .cshtml page was handling it based on some event response, using a script that removed the "invisible" from its css. So, on hitting the browser back button the event would not be called and hence the button was still invisible. I needed to make the button visible. The only workaround I found was this -- a hidden check included in the target page after hitting the browser back button.

    <script type="text/javascript">
       onload = function () {
         var e = document.getElementById("reloaded");
         if (e.value == "no") e.value = "yes";
         else { e.value = "no"; location.reload(); }
       }
    </script>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top