Creating Your Own Web Browser in Less Than Five Minutes with Microsoft Visual C# 2008 Express Edition

  • 3/5/2008

Putting It All Together

You’ve just seen that when you drag a control to the design surface, you’re actually creating an object of that control class. When you’re naming the control in the Properties window, you’re actually assigning a name to the variable you’ve just created—which is exactly what you did for the three controls used in your browser. In fact, this is why you want to give your controls meaningful names so that you can use them later programmatically.

As you now know, a great deal of activity was taking place when you dropped controls on the designer surface. To help you understand what took place in the background, we talked about important OOP concepts behind the line of code you added to respond to the Click event.

Now that you’ve run the application, here is a list of questions you may have:

  • What happens if I put nothing in the text box and hit Enter?

  • What happens if I enter an invalid URL?

  • What happens if I enter anything I want?

My answer to you is simply, “Try it. Try it now.” The real deal is that your Web browser will actually behave like any other Web browser and will navigate to whatever URL is typed into the text box. If you don’t type anything, clicking the GO button will have no effect. If you type something that isn’t a URL, the browser control will come back with a Page Not Found or Code 404 page.

Now is your time to experiment. Remember this book’s rule: try, try, try. Play with it. Change some of the properties, and see the results at run time. Although we haven’t used many features yet, you’ll add more in Chapter 6. This project is far from over! By adding new features, you’ll arrive at a point where your application will start to look much more familiar.