web browser question

daveofgv

Well-known member
Joined
Sep 17, 2008
Messages
218
Location
Dallas, TX
Programming Experience
1-3
I have a webbrowser on a form and everything works great, however, right now, the webbrowser navigates to where the url is (www. vbdotnetforums.com), but when you click a link it dosn't update the textbox with the new url (http ://www vbdotnetforums.com/security/34004-login-problem.html). It just stays at the first url.... Anyone know how to fix this?

thanks in advanced

daveofgv
 
Would it be possible to explain a little more?

What I have right now is:
VB.NET:
Public Class browser
    Public Declare Function GetASyncKeyState Lib "user32" Alias "GetASyncKeyState" (ByVal vKey As Long) As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

    End Sub

    Private Sub browser_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
     
    End Sub

    Private Sub browser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      
        Timer1.Interval = 7000

        WebBrowser1.Navigate(My.Settings.homepage)
    End Sub

    Private Sub ProgressBar1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProgressBar1.Click

    End Sub

    Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
        Timer1.Start()
    End Sub

    Private Sub WebBrowser1_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
        ProgressBar1.Maximum = e.MaximumProgress
        ProgressBar1.Value = e.CurrentProgress

    End Sub

    Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click
    
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)





    End Sub

    Private Sub ToolStripTextBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripTextBox1.Click
     
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub ChangeHomePageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangeHomePageToolStripMenuItem.Click
        enterhomepage.Show()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ToolStripTextBox1.Items.Add(WebBrowser1.Url.ToString)
        Timer1.Stop()
    End Sub

    Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Forward.Click
        WebBrowser1.GoForward()

    End Sub

    Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Back.Click
        WebBrowser1.GoBack()

    End Sub

    Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        WebBrowser1.Stop()

    End Sub

    Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Home.Click
        WebBrowser1.Navigate(My.Settings.homepage)
    End Sub

    Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click
        WebBrowser1.Navigate(ToolStripTextBox1.Text)

    End Sub

    Private Sub ToolStripButton7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Refresh.Click, Refresh.Click
        WebBrowser1.Refresh()

    End Sub

    Private Sub ViewPageSourceToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewPageSourceToolStripMenuItem.Click
        Dim HTMLBody, HTMLTrunc As String
        Dim HTMLDoc As mshtml.HTMLDocument
        HTMLDoc = WebBrowser1.Document.DomDocument
        HTMLBody = HTMLDoc.body.outerHTML
        HTMLBody = HTMLDoc.body.innerHTML
        HTMLTrunc = Mid(HTMLBody, 1, 5000000)
        viewurlsourcecode.TextBox1.Text = (HTMLTrunc)
        viewurlsourcecode.Show()




    End Sub

    Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked

    End Sub

 

    Private Sub Button1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)

    End Sub

    Private Sub ToolStripTextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ToolStripTextBox1.KeyDown
        If e.KeyCode = System.Windows.Forms.Keys.Enter Then
            WebBrowser1.Navigate(ToolStripTextBox1.Text)

        End If

    End Sub
End Class

Some if it I have to clean up still. I am building a kiosk program for a local hotel (a small hotel that a friend owns) which hides the taskbar, start menu and disables ctrl+esc, atl+tab and alt+F4. I have almost everything complete except for the url problem.......

Could you explain what I need to do a little more in depth?

Thanks in advanced
 
In the DocumentCompleted event handler you need to use the WebBrowser's Url property (I mistakenly called it Uri before) to get the current address and display that in your TextBox.
 
Back
Top