Solved

How to disable backspace button in a web browser control + C# win forms

Posted on 2010-09-15
4
3,295 Views
Last Modified: 2012-05-10
Hi,

I would like to disable back space button for web browser control. even though if the user presses backspace button it should not navigate to previous page.

I'm using vs 2005 . is there any way to do that.

Thanks in advance.
0
Comment
Question by:MEDIZ
4 Comments
 
LVL 5

Expert Comment

by:Varghese Jacob
ID: 33690271
Hope the below link will help you.
http://www.webmasterworld.com/forum91/4699.htm
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33848203
Another remark: disabling the back-button !

I have had a lot of people ask, "How to I disable the back button?" or, "How do I prevent a user from clicking the back button and going back to the previous screen?" In fact, this is one of the most commonly asked questions on the ASPMessageboard and, sadly, the answer is quite simple: You CANNOT disable the back button of the browser.

Source: http://www.4guysfromrolla.com/webtech/111500-1.shtml
0
 
LVL 8

Expert Comment

by:Subrat (C++ windows/Linux)
ID: 33930775
Work arround might be keyboard hook. While user press back btn, display a message like "Sorry! can't go back"
0
 
LVL 8

Accepted Solution

by:
davesgonebananas earned 250 total points
ID: 34098310
You can subclass the WebBrowser control and override the PreProcessMessage function.  However, if you filter out all Backspace key events then users won't be able to delete mistakes in forms :/
    public partial class MyWebBrowser : System.Windows.Forms.WebBrowser
    {
        public MyWebBrowser()
        {
            InitializeComponent();
        }

        public MyWebBrowser(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
        }

        public override bool PreProcessMessage(ref System.Windows.Forms.Message msg)
        {
            if ((msg.Msg == 0x100) && (msg.WParam == (IntPtr)Keys.Back)) 
            {
               // return true;
            }

            return base.PreProcessMessage(ref msg);
        }

    }

Open in new window

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with my python script 6 163
pre4 challenge 19 100
sumDigits  challenge 7 92
Programatically extract date from website 8 77
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This video teaches viewers about errors in exception handling.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question