C# Newbie Question. Making button as a link, open in attached WebB

G

Guest

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(object sender, EventArgs e)
{

}

private void progressBar1_Click(object sender, EventArgs e)
{

}

private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{

}

private void frmMain_Load(object sender, EventArgs e)
{

}

private void btnPrint_ContextClick_1(object sender, EventArgs e)
{
webBrowser.Print();
}

private void btnXMFINFO_ContextClick(object sender, EventArgs e)
{
webBrowser.Navigate ("http://www.google.com");
}
private void btnEXEC_ContextClick(object sender, EventArgs e)
{
webBrowser.Navigate("http://www.google.com");
}
private void btnENGR_ContextClick(object 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(object sender, EventArgs e)
{
webBrowser.Navigate("http://www.google.com");
}
private void btnHUMA_ContextClick(object sender, EventArgs e)
{
webBrowser.Navigate("http://www.google.com");
}
private void btnSHIP_ContextClick(object sender, EventArgs e)
{
webBrowser.Navigate("http://www.google.com");
}
private void btnPLAS_ContextClick(object sender, EventArgs e)
{
webBrowser.Navigate("http://www.google.com");
}
private void btnSPEC_ContextClick(object 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
 
P

Peter van der Goes

Chris said:
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?
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
If the purpose of these buttons is simply to allow URL navigation, why not
just use the Hyperlink control? You can easily change the default appearance
to "button-like" by setting properties such as foreground, background colors
and border color and style.
 
G

Guest

Hello, and thank you for the reply.
These are special 'graphical" image buttons, that go along with the theme of
the form.
Is it not possible to make a button function as a link?

Thanks!

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top