Problem and Solutions

2

Like

How to stop using BACK and Forward button of the borwser in ASP.NET?


Hi

I am developing a Web App using ASP.NET and C#. I need to stop using BACK and Forward button of the borwser.


Please help me to do this

Regards
James
Posted by: James
On 16 Mar 2012 | Views: 2405 | Categories: C#, ASP.NET
Solutions(1)
 On 25 Mar 2012 11:00:17 AM
This function use for disabling back button of browser.
If you want prevent to go back from browser so use follwing method instead of
response.redirect();

public string Disable_Back_Button(string nextpage_url)
{
try
{
string strScript;
strScript="<script language="javascript">";
strScript=strScript+"{";
strScript=strScript+" var Backlen=history.length;";
strScript=strScript+" history.go(-Backlen);";
strScript=strScript+" window.location.href='" + nextpage_url + "'; ";
strScript=strScript+"}";
strScript=strScript+"</script>";
return strScript;
}
catch(Exception ex)
{
throw ex;
}
}

Example for use:
Response.Write(Disable_Back_Button("nextpage.aspx"));
instead of response.redirect("nextpage.aspx");
Post your Solutions  

 

Other lins

.Net Techies
Other lins