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
 

Home button in Web Browser Control Application using C# .net 2.0

Author: Zunnair
Download Source Code : 820_Home.zip

In this simple article you will learn that how to make “Home” button in Web Browser Application (Web Browser Control Application)

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

·         One button will use for loading page which I have discuss in one of my previous articles.

·         Other one will be used to load “Home Page”.

 

Now write the following code on Form Load event:

C#

private void LoadForm_Browser(object sender, EventArgs e)

        {

            this.Text = "DevAsp WebBrowser Application";

            this.txt_Url.Text = "www.devasp.net";

            wbBrwsr.Navigate(txt_Url.Text);

        }

VB

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

        Me.Text = "DevAsp WebBrowser Application"

        Me.txt_Url.Text = "www.devasp.net"

        wbBrwsr.Navigate(txt_Url.Text)

    End Sub

Now write the following code on button click event:

C#

private void btn_Home_Click(object sender, EventArgs e)

        {

            wbBrwsr.GoHome();

          

        }

VB

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

        wbBrwsr.GoHome()

    End Sub

This code will load default home page sat buy window or internet explorer.

You can set your own home page by typing following code.

C#

private void btn_Home_Click(object sender, EventArgs e)

        {

          

wbBrwsr.Navigate(“www.devasp.net”);

        }

VB

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

 

        wbBrwsr.Navigate(www.devasp.net)

    End Sub

You can also set home page at run time. For this you will have to take address from user on run time as a string and pass the string as parameter in the above code.

This is the simple code for adding Home button (setting home page) in web Browser control application.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Search” and”Print” buttons in Web Browser Control Application using C# .net 2.0

Disclaimer - Privacy
© 2002-2017 DevASP.net