Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 3 - Displaying HTML Content with a Web Browser...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Displaying HTML Content with a Web Browser Control in Visual Basic
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 17
    2006-05-10

    Table of Contents:
  • Displaying HTML Content with a Web Browser Control in Visual Basic
  • Embedding a web browser control into a Windows form
  • Creating a user interface for testing
  • How to display HTML content generated by a program

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Displaying HTML Content with a Web Browser Control in Visual Basic - Creating a user interface for testing


    (Page 3 of 4 )

    Create a UI as shown in Fig.2, displaying the design view with a command button, a text box, a label and the web browser. The web browser control can be dragged from the tool box and dropped on the form as shown below the button. It can be sized to your liking. The figure shows all these items on the form "Displaying with web browser." Move to the web page, look at the code view, and you will see all these items in the "General" drop down menu where the web browser control is referred to as WebBrowser1.

    Fig.2

    Now take a look at the control's methods, properties, and so forth by bringing up the Object browser window by clicking View -> Object Browser as shown in Fig.3. If you click on SHDocVwCtl you will see the various classes and class members of the web browser control. Although we will be using just one method of this control, you can see that there is rich functionality associated with this control, including the history of the page through Go back, Go forward and so on; the down loading of content; data binding, and more. Since the control is seen in the object browser you could access the properties and methods in the code assisted by intellisense. Out of all these properties and methods we will use one method, called Navigate(), which takes a URL as an argument.

    Fig.3

    Now click on the button and add the following code. Since intellisense is in effect, if you type webbrowser1 and insert a period after it, you will get the drop down menu with all associated applicable methods, properties, and events for this control as shown in Fig.4. Here is the complete reference to all the properties and methods for this control.

    Private Sub Command1_Click()
    WebBrowser1.Navigate (Text1.Text)
    End Sub
    
    Fig.4

    Now passing a URL as a reference you can display the web page as shown in Fig.5.

    Fig.5

    In addition to a URL you may also use a full file path, or a path on a network drive for a display. For example each of the following will display the same page without an error.

    URL: http://localhost/URLRef.htm
    UNC Path: hodentekstagerURLRef.htm
    Full reference: C:URLRef.htm
    

    In addition to the .htm file you may also display *.xml, *.rtf and *.doc files in the web browser by navigating to the file, and when required the Open or Save option is presented, choose open. The document will be opened inside the web browser.

    More Visual Basic.NET Articles
    More By Jayaram Krishnaswamy


       · Web browser control is a very useful ActiveX control. There is a .NET twin as well...
       · Yikes! I don't know about your researching skills. Check out the following MSDN...
       · Thanks for the comment and drawing my attention to the MSDN article. This article...
     

    VISUAL BASIC.NET ARTICLES

    - Creating and Drawing a Game Map in VB.NET
    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway