I am making a web-based student entrance examination using ASP.Net which uses Visual Basic and some java script. I want to disable or remove the functionality of the back button of Internet Explorer so that the student will not be able to go back to the previous page when she/he already clicked the “Next” button.
How to disable back button of a web browser in ASP.Net?
Using ASP.Net, you can easily build a program much quicker than when using other web programming tools. You can build programs with less coding and it is also the same as HTML; it can contain XML and Scripts. The ASP.Net scripts are run from the server. If you want to modify such functionality of a web browser you can follow the codes below:
Copy and paste this java script after the <title></title> tag and within the <head runat=”server”> </head> tag.
<script language="javascript" type="text/javascript">
<!–
javascript:window.history .forward (1);
//–>
</script>
Whenever the user clicks the back button on the Internet Explorer the previous page will not allow it. So you must put this code on a web page wherein the user is trying to reload. If you want to use this code when running on Firefox, it might not work so you must set your default browser to Internet Explorer if you really want this to work.
How to disable back button of a web browser in ASP.Net?
Hi Marry,
Simply put the following code within your <head> tags on the page source
<script type="text/javascript" language="JavaScript">
this.history.forward(-1);
</script>
Let’s imagine you have two pages, First page and second page. You need to put above code with in the first page <head> tags. Once you navigate to the second page from the first page you’ll see that you can’t go back to the previous page. If you are using a master page use the above code directly in the master page so that you don’t need to update the <head> tags of each and individual page.
Thanks.