Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How to use web browser control in .net 2.0. (Part1)

Author: Zunnair
Download Source Code : 814_web browser.zip

In this simple article you will learn that how to use Web Browser control in C# .net 2.0.

 Create new c# project. Drag one Textbox control, Label, Web Browser control, and one button on the windows form.

Now write code on form load event:

C#

private void FrmWebBrowser_Load(object sender, EventArgs e)

        {

            this.Text = "DevAsp Web Browser";

            txt_Url.Text = "www.google.com.pk";

            wbBrwsr.Navigate("www.google.com.pk");

            this.WindowState = FormWindowState.Maximized;

        }

VB

Private Sub FrmWebBrowser_Load(ByVal sender As Object, ByVal e As EventArgs)

        Me.Text = "DevAsp Web Browser"

        txt_Url.Text = "www.google.com.pk"

        wbBrwsr.Navigate("www.google.com.pk")

        Me.WindowState = FormWindowState.Maximized

    End Sub

Now write the following code on button click event:

C#

private void btn_Go_Click(object sender, EventArgs e)

        {

            wbBrwsr.Navigate(txt_Url.Text);

        }

 

VB

 

Private Sub btn_Go_Click(ByVal sender As Object, ByVal e As EventArgs)

        wbBrwsr.Navigate(txt_Url.Text)

    End Sub

 

It will get url address or string from the text box named “txt_Url” and load the site on the WebBrowser Control page.

 

Use Anchor property of WebBrowser control to maximize the WebBrowser page when the form get maximized.

 

Use  Url  property  to  set  the default page which will load first time automatically when the program will execute.

 


   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Sort all Strings in DomainUpDown control on run time using .net 2.0

Disclaimer - Privacy
© 2002-2017 DevASP.net