HiTechFox
asked on
C# Newbie Question. Making button as a link, open in attached WebBrowser Form
Hello all.
I am making a small silly little basic one page web form while learning C# (Using VS 2005 Express). I am stuck on how to link a button I have created, to actually send the user to a specified URL when clicked, into the attached WebBrowser form.
I thought
WebBrowser.Navigate ("http://www.google.com");
should do the trick, under each button, but they still do nothing. What n00bish thing am I missing here?
Attached is my code:
#region Using directives
using System;
using System.Collections.Generic ;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
#endregion
namespace New
{
partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private void btnPrint_ContextClick(obje ct sender, EventArgs e)
{
}
private void progressBar1_Click(object sender, EventArgs e)
{
}
private void printDocument1_PrintPage(o bject sender, System.Drawing.Printing.Pr intPageEve ntArgs e)
{
}
private void frmMain_Load(object sender, EventArgs e)
{
}
private void btnPrint_ContextClick_1(ob ject sender, EventArgs e)
{
webBrowser.Print();
}
private void btnXMFINFO_ContextClick(ob ject sender, EventArgs e)
{
webBrowser.Navigate ("http://www.google.com");
}
private void btnEXEC_ContextClick(objec t sender, EventArgs e)
{
webBrowser.Navigate("http://www.google.com");
}
private void btnENGR_ContextClick(objec t sender, EventArgs e)
{
webBrowser.Navigate("http://www.google.com");
}
private void btnMETAPURCH_ContextClick( object sender, EventArgs e)
{
webBrowser.Navigate("http://www.google.com");
}
private void btnACCO_ContextClick(objec t sender, EventArgs e)
{
webBrowser.Navigate("http://www.google.com");
}
private void btnHUMA_ContextClick(objec t sender, EventArgs e)
{
webBrowser.Navigate("http://www.google.com");
}
private void btnSHIP_ContextClick(objec t sender, EventArgs e)
{
webBrowser.Navigate("http://www.google.com");
}
private void btnPLAS_ContextClick(objec t sender, EventArgs e)
{
webBrowser.Navigate("http://www.google.com");
}
private void btnSPEC_ContextClick(objec t sender, EventArgs e)
{
webBrowser.Navigate("http://www.google.com");
}
}
}
Notice I am using about 9 buttons I am wanting to attach to a different URL (buttons named btnINFOMARK, etc.). I want these buttons to hold a URL, and when clicked, open the corresponding URL in the WebBrowser component that is on the same form.
Please help! =)
Thanks,
Chris
I am making a small silly little basic one page web form while learning C# (Using VS 2005 Express). I am stuck on how to link a button I have created, to actually send the user to a specified URL when clicked, into the attached WebBrowser form.
I thought
WebBrowser.Navigate ("http://www.google.com");
should do the trick, under each button, but they still do nothing. What n00bish thing am I missing here?
Attached is my code:
#region Using directives
using System;
using System.Collections.Generic
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
#endregion
namespace New
{
partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private void btnPrint_ContextClick(obje
{
}
private void progressBar1_Click(object sender, EventArgs e)
{
}
private void printDocument1_PrintPage(o
{
}
private void frmMain_Load(object sender, EventArgs e)
{
}
private void btnPrint_ContextClick_1(ob
{
webBrowser.Print();
}
private void btnXMFINFO_ContextClick(ob
{
webBrowser.Navigate ("http://www.google.com");
}
private void btnEXEC_ContextClick(objec
{
webBrowser.Navigate("http://www.google.com");
}
private void btnENGR_ContextClick(objec
{
webBrowser.Navigate("http://www.google.com");
}
private void btnMETAPURCH_ContextClick(
{
webBrowser.Navigate("http://www.google.com");
}
private void btnACCO_ContextClick(objec
{
webBrowser.Navigate("http://www.google.com");
}
private void btnHUMA_ContextClick(objec
{
webBrowser.Navigate("http://www.google.com");
}
private void btnSHIP_ContextClick(objec
{
webBrowser.Navigate("http://www.google.com");
}
private void btnPLAS_ContextClick(objec
{
webBrowser.Navigate("http://www.google.com");
}
private void btnSPEC_ContextClick(objec
{
webBrowser.Navigate("http://www.google.com");
}
}
}
Notice I am using about 9 buttons I am wanting to attach to a different URL (buttons named btnINFOMARK, etc.). I want these buttons to hold a URL, and when clicked, open the corresponding URL in the WebBrowser component that is on the same form.
Please help! =)
Thanks,
Chris
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER