How to disable back button of a web browser in ASP.Net?

Asked By 200 points N/A Posted on -
qa-featured

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.

SHARE
Best Answer by Nick Cowell
Best Answer
Best Answer
Answered By 0 points N/A #126041

How to disable back button of a web browser in ASP.Net?

qa-featured

 

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.
Answered By 5 points N/A #126043

How to disable back button of a web browser in ASP.Net?

qa-featured

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.

Related Questions