---
title: "How can I call webbrowser from another form c#"  
description: "How can I call webbrowser from another form c#"  
author: "Mark Devid"  
published: 2013-10-05  
updated: 2013-10-05  
canonical: https://www.mindstick.com/forum/1585/how-can-i-call-webbrowser-from-another-form-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# How can I call webbrowser from another form c#

I took two [form](https://www.mindstick.com/forum/6/multi-form-mfc-application) (form1 &[amp](https://www.mindstick.com/forum/156207/what-is-amp); form2) in my program. in form1 i took a [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) & in form2 i took a webbrowser.i want to run webbrowser on form2 by clicking on form1 button.

but my program not working.

Please help me, how to do this currently.

this is my [program code](https://www.mindstick.com/interview/33814/what-will-be-the-output-of-following-program-code):

\

```
public partial class Form1 : Form{    public Form1()    {
        InitializeComponent();
    }
    private void progressBar1_Click(object sender, EventArgs e)    {
    }
    private void button1_Click(object sender, EventArgs e)    {        try         {
            webBrowser1.Navigate(textBox1.Text);
        }
        catch(Exception)        {
            MessageBox.Show("Connect to Internet First","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
        }
    }
    private void Form1_Load(object sender, EventArgs e)    {
    }
}
```

\

## Replies

### Reply by Dag Hammarskjold

First, in form1.designer, change this line of [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii):

```
private System.Windows.Forms.WebBrowser webBrowser1;
```

to:

```
public System.Windows.Forms.WebBrowser webBrowser1;
```

now, in form1 button_click:

```
    Form2 f = new Form2();
    f.webBrowser1.Navigate("http://www.mindstick.com");
    f.Show(this);
```

solution II: In form1:

```
private void button1_Click(object sender, EventArgs e)
{
    Form2 f = new Form2();
    f.Url = "http://www.mindstick.com";
    f.Show(this);
}
```

\

In form2:

```
public string Url { get; set; }

    private void Form2_Load(object sender, EventArgs e)
    {
        this.webBrowser1.Navigate(this.Url);
    }
```

\


---

Original Source: https://www.mindstick.com/forum/1585/how-can-i-call-webbrowser-from-another-form-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
