C# .NET - Disabling back button of IE window using c#

Asked By svt gdwl on 04-Jun-09 12:33 AM
I was trying to disable back button of IE window in the following way but
the back button on top left corner of IE is not disabled.

           document = (HTMLDocument)webBrowser.Document;
           string javaScriptcode = "javascript:window.history.forward(1);";
           IHTMLWindow2 parentWindow = document.parentWindow;
           parentWindow.execScript(javaScriptcode, "javascript");

How can I do this

RE

Ravenet Rasaiyah replied to svt gdwl on 04-Jun-09 12:53 AM
Hi

If you are dooignin window form  web browser you can disable like this way


webBrowser1.CanGoBack = false;

if you are doing with asp.net with c# you can do like this way also

// Disable the Cache
Response.Buffer= true;
Response.ExpiresAbsolute=DateTime.Now.AddDays(-1d);
Response.Expires =-1500;
Response.CacheControl = “no-cache”;


thank you


Santhosh N replied to svt gdwl on 04-Jun-09 01:04 AM

Well, disabling the browser back button is a misnomer to be specific...

Actually, one could not disable the browser back button of IE like the one you do in an aspx page (button)...

Here, any post suggesting a way to disable the browser back button is just like wiping the history entries out or preventing to go back to the prev page in the browser through scripting (javascript code) but not really disbaling the button (graying out the button)

I hope I am clear in depicting the real picture to you, if not let me know for your further clarifications...

cheers

I was doing on web forms, not window forms

svt gdwl replied to Ravenet Rasaiyah on 04-Jun-09 01:05 AM
I was doing through BHO which gets injected on IE6