Results 1 to 5 of 5

Thread: [2005] URL changed via Textbox

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2007
    Posts
    56

    [2005] URL changed via Textbox

    Hello, I'm having a bit of trouble changing a web browser's URL. I have tried a simple piece of code:

    WebBrowser1.Url = TextBox1.Text

    Which looks like it should work.
    It gives an error saying:

    Value of type 'String' can not be converted to 'System.Uri'

    Can anyone shed some light on this?

    Thanks in advance.

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] URL changed via Textbox

    either one of these should work fine for navigating the browser to a given URL

    Code:
            WebBrowser1.Url = New Uri(textbox1.Text)
            WebBrowser1.Navigate(textbox1.Text)

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2007
    Posts
    56

    Re: [2005] URL changed via Textbox

    Yeah they work fine.
    Thanks.

    Erm ...

    How about changing the URL to a string, so like, the Text Box would read the Web Browser's URL constantly?

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: [2005] URL changed via Textbox

    Quote Originally Posted by Deadly Asphyxiation
    How about changing the URL to a string, so like, the Text Box would read the Web Browser's URL constantly?


    Text Boxes can't read.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] URL changed via Textbox

    You use the Navigated event of the browser (which fires right when navigation has started) and you grab the URL of the browser there.
    Code:
        Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
            textbox1.Text = WebBrowser1.Url.ToString
        End Sub

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