none
How to have a button go to a website

    Question

  • hello, i got a app with a web browser and some buttons, I want a button to make the browser go to google, how do i do that???
    Tuesday, November 08, 2016 7:46 PM

Answers

All replies

  • Tuesday, November 08, 2016 8:03 PM
  • Can you write an example, I am still learning and can't write it.
    Wednesday, November 09, 2016 12:52 AM
  • Hi Mr.Developer144,

    If you have "webBrowser1" on your Windows Form "frmWebBrowser", code would be like below.

    VB.Net
    WebBrowser1.Url = New Uri("http://www.google.com")
    frmWebBrowser.Show()

    ReRegards,
    Ashidacchi
    Wednesday, November 09, 2016 5:39 AM
  • Hi Mr.Developer144,

    Welcome to the MSDN forum.

    Which application did you created? To achieve your requirement, take C#-Windows Forms application for example, you can have a look at the following steps:

    1. Create a new Windows Forms application: New-Project-Visual C#-Windows Forms Application

    2. Double click the file ‘Form1.cs’ under Solution Explore to open Form1.cs[Design] in Editor windows

    3. Click Toolbox and add a button and a WebBrowser into the Form1 and save it

    4. Double click the above button to open the Form1.cs file to type the code

    5. Add the code to define the webBrowser1.url to invoke the google website like the following:

    private void button1_Click(object sender, EventArgs e)

            {

                webBrowser1.Url = new Uri("https://www.google.com");

            }

    6. Build and start this solution and I got the result as below:

    Meanwhile, I shared this above simply solution in here: https://1drv.ms/u/s!Atv5QNuFrncKglwR1pe3T9JyMsWa

    For other project types, the code may be similar with above, you can have a try. If you still have any issues, please feel free to let me know.

    Best regards,

    Sara


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 09, 2016 5:39 AM
    Moderator
  • i don't have frmWebBrowser, Also i am using Visual Basic

    Wednesday, November 09, 2016 11:57 AM
  • Hi Mr.Developer144,

    I have tried the code WebBrowser1.Url = New Uri("http://www.google.com")

    like the steps like my last reply and it works fine in VB-Windows Form application like the following screenshot, what's your current problem?

    Best regards,

    Sara


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 10, 2016 8:39 AM
    Moderator
  • I got it to work, I did WebBrowser1.Navigate(http://www.______.com)
    Wednesday, March 01, 2017 1:44 PM
  • Hi Mr.Developer144,

    I'm so glad to hear that your issue is solved and thanks for your sharing.

    Best regards,

    Sara


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 02, 2017 2:03 AM
    Moderator