Click here to Skip to main content
15,889,879 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have added a webbrowser tool in a form to browse some webpage. how can i clear the contents of tht webbrowser ?????? i want c# code .. ...
thanks
Posted
Updated 7-May-13 2:13am
v2

webBrowser1.Navigate("about:blank");
 
Share this answer
 
Comments
deep@2 8-May-13 10:50am    
thanks :)
I asked the same question!

Here is the Navigate(string URL) function:

C#
private void Navigate(String address)
{
    if (String.IsNullOrEmpty(address)) return;
    if (address.Equals("about:blank")) return;
    if (!address.StartsWith("http://") &&
        !address.StartsWith("https://"))
    {
        address = "http://" + address;
    }
    try
    {
        webBrowser1.Navigate(new Uri(address));
    }
    catch (System.UriFormatException)
    {
        return;
    }
}

Then do:

C#
String URL = "";

textBox1_Click(object sender, EventArgs e)
{
     //updates the URL
     URL = textBox1.Text;
}

buttonGo_Click(object sender, EventArgs e)
{
      //changes the site
      Navigate(URL);
}


You can add better disign and more!

I'd like I was helpful!

:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900