|
-
May 22nd, 2006, 05:46 AM
#1
Thread Starter
Lively Member
[RESOLVED] [2005] Hyperlink/Onclick open page in browser
It seems when I want something explained in a complex way I find examples that only show the barest of minimum steps, and then the reverse is also true. I've spent several days on this problem too.
I have one simple hyperlink control and when the user clicks on it, I'd like a browser to open with the page indicated in the control.
I find all kinds of examples scrolling through this or that or appending text to this or that. I just want to launch a darn page. I've done menus and hyperlinks for years in Access and VB 6.0, I just don't know what I'm doing wrong in VB 2005. Sheesh! Oops, sorry for venting. Any advice would be greatly appreciated, I've already searched high and low, not sure what I'm missing.
Here is my glamorous code:
VB Code:
Private Sub llHyperlink_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles llHyperlink.LinkClicked
'www.microsoft.com is also the text of the hyperlink control.
Dim url As String = "www.microsoft.com"
Dim browser As WebBrowser
'the text must stay white for all states of the click events, "not visited, visited, etc."
browser.Navigate(url)
End Sub
Last edited by Christineeve; May 22nd, 2006 at 01:23 PM.
Reason: [RESOLVED]
-
May 22nd, 2006, 06:13 AM
#2
Re: [2005] Hyperlink/Onclick open page in browser
So are you saying that you want to open this page in a new window of the default browser or in a WebBrowser control on your form?
If it's a WebBroswer control on your form then you need to use a WebBroswer control that's on you form. That code of yours declares a WebBrowser variable but doesn't create a WebBrowser object, and even if it did it isn't added to the form so the user would never see it.
-
May 22nd, 2006, 06:18 AM
#3
Thread Starter
Lively Member
Re: [2005] Hyperlink/Onclick open page in browser
 Originally Posted by jmcilhinney
So are you saying that you want to open this page in a new window of the default browser or in a WebBrowser control on your form?
If it's a WebBroswer control on your form then you need to use a WebBroswer control that's on you form. That code of yours declares a WebBrowser variable but doesn't create a WebBrowser object, and even if it did it isn't added to the form so the user would never see it.
I'm saying when the user clicks on the hyperlink control, an external webpage opens and displays the website. I definately do not want it to open inside my application.
-
May 22nd, 2006, 01:19 PM
#4
Thread Starter
Lively Member
Re: [2005] Hyperlink/Onclick open page in browser
Ok,
I finally found this after looking for days. It really couldn't have been easier.
Thanks for pointing me in the right direction.
Here's what I did:
VB Code:
Try
' Dim browser As WebBrowser
System.Diagnostics.Process.Start("http://www.microsoft.com")
Catch ex As Exception
If Err.Number <> 0 Then
errLogger(Err.Number, Err.Description, Err.Source)
End If
Exit Sub
End Try
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|