Click here to Skip to main content
15,946,699 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What code can I use to open a from a button click ?

Try This


That will open up the web page in the users default browser. If the browser is open it will just open a new tab page.

Hope this helps.

Happy Coding
Share this answer
If you are using windows application,
You need a WebBrowser Control on the form. Then on the button click, write this code:
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
    webBrowser1.Url = New Uri("")
End Sub

If it's an web application,
Do something like this:
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
End Sub

Hope this helps!
Share this answer
Thanks for the quick reply, but how do I declare help ?
Share this answer
Wayne Gaylard 13-May-10 9:43am    
You just type it exactly as I typed it in the click event handler. You don't need to import anything. It is part of the HTML Help Engine which is automatically included in any windows application project. It is a bit of a hack but it works perfectly.
The help is underlined in blue and asks for that help be named?

I just want to open from a form in a web browser using button click.
Share this answer
Wayne Gaylard 13-May-10 10:03am    
What version of VS are you using. In VS2008 using .Net 3.5 it is a normal Keyword for VB.Net and C#.
Wayne Gaylard 13-May-10 10:12am    
In fact I just opened a new project in VS 2005 with .Net 2.0 and it also works perfectly.
SG0001 13-May-10 10:22am    
VS 2005 and coding in VB but I keep getting help. not declared and when compiling wont open shows errors?
Rather than using any web browser control use my code it will give u your desired output for sure. Now below code is in c# it dont worry the technique is all same with VB.NET
its very easy to do this all u have to do is this
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics; //use this namespace

namespace Run
    public partial class Form1 : Form
        public Form1()

//on button click write this piece of code
        private void button1_Click(object sender, EventArgs e)

the above code will open your site in internet explorer or your default selected browser

DO Rate my answer once you find it useful

Thanks & Regards
Radix :)
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