?
Solved

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

Posted on 2005-04-02
2
Medium Priority
?
269 Views
Last Modified: 2008-03-06
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
0
Comment
Question by:HiTechFox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
TDSnet earned 200 total points
ID: 13713563
G'day Chris,

You could use the page's Response object to redirect the browser to the new URL.

ie.

private void btnMETAPURCH_ContextClick(object sender, EventArgs e)
{
    this.Response.Redirect("http://www.google.com.au")
}

Cheers,

Jack Pick
Total Data Solutions
0
 
LVL 1

Author Comment

by:HiTechFox
ID: 13715748
Thank you very much!!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question