HOW TO: Develop Simple Web Browser Using C# [With URL Navigating]

Written by in Featured, Guides - Print This Post



This tutorial will explain, how to develop a Web browser which Navigate URL in the Text Box using C#(Sharp). Text Box mentioned here is the address bar of your Web Browser. PreviousIy I have written some article about how to develop a Simple Web Browser and how to add some features to it using C# (Sharp), you can refer that for more details. You are recommended to use Microsoft Visual Studio.

We have screen shots here and have a look at it, same URL but two different blog contents, doesn’t it look annoying? When you execute the Bowser, it automatically loads Hellboundbloggers.com content and after I click on Home Button, browser loads tekkieblog content. The issue here is, it will not display the URL of tekkieblog.com in the Adress bar. When I again click on back button it loads Hellboundbloggers.com content with HBB URL in the Adress bar. There is no change in the URL because the Adress bar does not Navigate the URL and it only displays the content. So, to display appropriate URL in the Address bar while Navigating, we have to fire two events namely Text Changed Event of the Text Box and the Navigated Event of the Web Browser Control.

TekkieBlog - Tekkie Browser

Text Changed Event of the Text Box

Install Microsoft Visual Studio if you haven’t. After that, right click the Text Box in the design mode and select Properties and then select events in the Properties window and move to Text Changed event and double click it.

The TextChanged event is raised when the content of the text box changes between posts to the server. Add the following code snippet.


private void textBox1_TextChanged(object sender, EventArgs e)
{
webBrowser1.Navigate(textBox1.Text);
}

Develop Web Browser I

Navigated Event of the Web Browser Control

Right click the Web Browser control in the design mode and select Properties and then select events in the Properties window and move to Navigated event and double click it.

The Web Browser control navigates to a new document whenever one of the following properties is set or methods is called Url, DocumentText, DocumentStream, Navigate, GoBack, GoForward, GoHome, GoSearch. Add the following code snippet.


private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
textBox1.Text = webBrowser1.Url.ToString();
}

HBB - Tekkie Browser

In my case, Web Browser control name is webBrowser1, Text Box name is textBox1, change the Text property of the Form to any name you like. Press F5 to start the Debugging or Debug –> Start Debugging.

This article is written by Narendran. He is the founder and editor of Tekkieblog. He always strives himself to find simple solution for complex problems. If you wish to write for us, kindly check this.









HBB RSS
Hello there! If you are new here, you might want to subscribe to the RSS feed for updates on this topic. You will also get instant access to 100+ HBB Guides & Tutorials.
If you wish to subscribe here via Email, then kindly click here.



Narendran.M is the owner of Tekkie Blog. He always strives himself to find simple solution for complex problems. He proudly says "ALWAYS THINK BIGGER, SO THAT YOU'LL REACH HIGHER".


HBB has 666+ Awesome Contributors. [Join HBB].

HellBound Bloggers (HBB) is a part of Slashsquare Network.






9 Responses to “HOW TO: Develop Simple Web Browser Using C# [With URL Navigating]”

Leave a Reply


Comments Policy | Brand Your Comments | Do Follow Blog | Top Commentators Award


REFERENCE : 7 Tips To Be A Hero On Blog Commenting [HELPFUL]


Overall HellBound Bloggers (HBB) has 23,573 Genuine Comments and Yours Will Add More Value To It.




Previous Article:

Next Article:

  1. Harsha says:

    U can refer the link : http://blog.spiharsh.com/building-webbrowser-using-c
    for more elobrated steps….

  2. Sidhant says:

    A web-browser in C-language, I think I got the project for my semester exams!
    Thanks! :D

  3. Vishnu says:

    Yay might try this for my bitfutura.org project :D

  4. Matt says:

    Simple but very useful feature to develop a Web browser which Navigate URL in the Text Box. Best of luck Narendran.

  5. Interesting! But I don't know much about C# while I completed C and C++in recent semesters.

  6. Abhishek says:

    this is really interesting..

  7. Taha says:

    Thank you bro this is really perfect :) I am making a bot now I am very new about C# language but your simple browser codes are help out me. Thanx again



Subscribe without commenting




COPYRIGHT © 2012 SLASHSQUARE NETWORK. REPRODUCTION WITHOUT EXPLICIT PERMISSION IS PROHIBITED. ALL RIGHTS RESERVED.

Slashsquare
Mobile Version · About Us · Contact Us · Subscription · Advertise · Review · Write For Us · Archives · Privacy Policy · Disclaimer
Loading...
ViperBarUp
ViperBarDown