C# – How to get a button to open a web page

cvisual studio 2010

I've looked everywhere, including the MSDN forums, but no one has even mentioned this or ways to do it. The basic idea is that once a Button is dragged from the toolkit, how do you then link that button to a web page, ie I have a 'Facebook' button, how do I then make it so that when the button is clicked, Facebook opens in a new browser window?

Best Answer

Once you've dragged the button onto the designer, you can double-click on it to open up the Button's Click event handler. This is the code that will get run when the user clicks. You can then add the required logic, ie:

private void button1_Click(object sender, EventArgs e)
{
    // Launch browser to facebook...
    System.Diagnostics.Process.Start("http://www.facebook.com");
}