Results 1 to 9 of 9

Thread: [RESOLVED] How to navigate a webbrowser only from a button?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Posts
    16

    Resolved [RESOLVED] How to navigate a webbrowser only from a button?

    Hi, I am extremely new to Visual Basic, and I have only so far made an e-mail sender and an SMS sender (through e-mail).

    So I am having troubles, I made a quick Web browser that I only want to show one page when you press a button ( you have to enter a name into a textbox and it will then make the URL to show), but the page has some links on it, which I don't want people to click on. I came up with a couple of solutions to my problem, which I don't even know if some of them are possible...
    1) Disable the hyperlinks
    2) Disable left clicks in the browser
    3) Make the browser somehow only visible and not actually interactive with a mouse

    I honestly have been searching for hours for a solution and also trying different things, but to no avail.

    So my question is are any of those three options possible? If not then what is an alternative? If so then which would be easiest and how would I go about doing so?

    Thanks for your time.

    Here is what I have in total:
    Code:
    Public Class Form1
        Private Sub TextBox1_keypress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
            If Asc(e.KeyChar) = Keys.Enter Then
                WebBrowser1.Navigate("http://firstpartoftheURL/" + TextBox1.Text + "secondpartoftheURL.html")
                e.Handled = True
            End If
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            WebBrowser1.Navigate("http://firstpartoftheURL/" + TextBox1.Text + "secondpartoftheURL.html")
        End Sub
    
    End Class
    I tried something like
    Code:
        
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            WebBrowser1.AllowNavigation = True
            WebBrowser1.Navigate("http://firstpartoftheURL/" + TextBox1.Text + "secondpartoftheURL.html")
            WebBrowser1.AllowNavigation = False
        End Sub
    Which I assumed would allow navigation once you clicked the button, but would then not allow it once you are done clicking it, but it just stays at false.
    Last edited by iambowling247; Aug 7th, 2009 at 05:20 PM.

  2. #2
    Hyperactive Member
    Join Date
    May 2008
    Location
    >> ( ҉ )
    Posts
    413

    Re: How to navigate a webbrowser only from a button?

    Hmm Donno. Answered but then i read the end :P

    Actually i tried same in 1 hour ago :P

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Posts
    16

    Re: How to navigate a webbrowser only from a button?

    Quote Originally Posted by Zeuz View Post
    Hmm Donno. Answered but then i read the end :P

    Actually i tried same in 1 hour ago :P
    I'm sorry man, but I have no idea what you just said, haha.

  4. #4

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Posts
    16

    Re: How to navigate a webbrowser only from a button?

    Quote Originally Posted by stateofidleness View Post
    put the wb control in a panel and disable the panel
    If you are talking about the design form then I just tried that and it just covers the webbrowser so than I can't see it, then I set the visibility to false and it then just lets me click everything in the webbrowser...

  6. #6
    Frenzied Member stateofidleness's Avatar
    Join Date
    Jan 2009
    Posts
    1,780

    Re: How to navigate a webbrowser only from a button?

    put the webbrowser IN the panel and set it's "Enabled" property.. not its "Visible" property

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Posts
    16

    Re: How to navigate a webbrowser only from a button?

    Quote Originally Posted by stateofidleness View Post
    put the webbrowser IN the panel and set it's "Enabled" property.. not its "Visible" property
    I did both to try them out, but I just got it, I had the panel on top of the browser, haha, thank you so much! Such a simple fix to something I have spent almost a whole day trying to fix!

  8. #8
    Frenzied Member stateofidleness's Avatar
    Join Date
    Jan 2009
    Posts
    1,780

    Re: How to navigate a webbrowser only from a button?

    good deal. rep if you feel like it and mark thread resolved!

    glad you got it working

  9. #9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width