Chapter 17. Web Development

Introduction

Programming for the Web is a vast subject worthy of a whole series of books. While we obviously can’t cover everything here, this chapter presents a few web-related recipes for Visual Basic that let you add some useful features to your applications. They will give you some idea of the power of web functionality combined with desktop applications. For a comprehensive collection of Visual Basic web recipes, see ASP.NET 2.0 Cookbook by Michael A. Kittel and Geoff T. LeBlond (O’Reilly).

17.1. Displaying Web Pages on a Form

Problem

You want to display a web page on your form, possibly built from custom HTML content.

Solution

Sample code folder: Chapter 17\CustomWebContent

Sample code folder: Chapter 17\ WebBrowser

Use the WebBrowser control. It encapsulates the core Microsoft Internet Explorer engine, and it integrates easily into your Windows Forms applications.

Discussion

This recipe’s sample code implements a simple web browser. Create a new Windows Forms application, and add the following controls to Form1:

  • A Panel control named WebToolbar. Set its Dock property to Top and its Size.Height property to about 40.

  • A WebBrowser control named WebContent. Set its Dock property to Fill. It should only fill below the Panel control. If it doesn’t, right-click on the Panel control and select “Send to Back” from the shortcut menu.

  • A Button control named ActBack. This control should appear on the surface of the Panel control. Set its Text property to &Back.

  • A Button ...

Get Visual Basic 2005 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.