Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening a website when a button on the form is clicked

Tags:

c#

.net

winforms

I am creating a windows application using C#, where in a button on the GUI when clicked, should open a website.

The web browser will be taken care of by the default settings.

I am curious as to how to do that?

like image 215
ykombinator Avatar asked Feb 01 '12 17:02

ykombinator


People also ask

How do I open a website when a button is clicked Android?

You can wrap the buttons in anchors that href to the appropriate website. When the user clicks the button (input) they are directed to the destination specified in the href property of the anchor.

What happens when submit button is clicked?

5. Most HTML forms have a submit button at the bottom of the form. Once all of the fields in the form have been filled in, the user clicks on the submit button to record the form data. The standard behaviour is to gather all of the data that were entered into the form and send it to another program to be processed.


2 Answers

If the point is to open a website in your application, you will have to use WebBrowser control. Put WebBrowser control on your form, and add this code to the button which is responsible for opening the site:

webBrowser1.Navigate("www.google.com");
like image 79
Krzysztof Cieslinski Avatar answered Nov 15 '22 22:11

Krzysztof Cieslinski


This will open the specified link in the default web browser:

Process.Start("http://www.google.com");
like image 32
stuartd Avatar answered Nov 15 '22 22:11

stuartd