Jump to content

  •  

  • iBotModz CBox


    Photo

    (C#)Navigate to URL


    • Please log in to reply
    2 replies to this topic

    #1 Lakar

    Lakar

      Private

    • Members+

    • 42 posts
    • Joined: 01-November 08

    Posted 11 May 2009 - 10:34 PM

    (C#)Navigate To URL

    This code will allow your text box to be used as a navigate to URL bar, this will work with a web browser placed on your program.

    Note : To get this to navigate to a URL, you will need to make a Go button to activate this code. (Go to bottom of thread to see code for this button)


    public void NavigateToUrl()
    		{
    			Uri URL = default(Uri);
    			try
    			{
    				URL = new Uri(textboxname.Text);
    			}
    			catch
    			{
    				try
    				{
    					URL = new Uri("http://www." + textboxname.Text);
    				}
    				catch
    				{
    					return;
    				}
    			}
    
    			if ((URL.HostNameType == UriHostNameType.Dns) | (URL.HostNameType == UriHostNameType.IPv4))
    			{
    				webbrowsername..Navigate(textboxname.Text);
    			}
    			else
    			{
    				string Host = URL.Host;
    				Host = "http://www." + Host;
    				try
    				{
    					webbrowsername.Navigate(Host);
    				}
    				catch
    				{
    				}
    			}
    		}


    Go Button Code
    private void gobutton_Click(object sender, EventArgs e)
    		{
    			if (ProgressBar1.Value < 100)
    			{
    				ProgressBar1.Value = 0;
    			}
    			NavigateToUrl();
    			if (ProgressBar1.Value < 100)
    			{
    				ProgressBar1.Value += 25;
    			}
    		}

    Enjoy
    -Lakar

    #2 Rogue Modder

    Rogue Modder

      Class of 2008

    • VIP

    • 1,328 posts
    • Joined: 02-January 09
    • Gender:Male
    • Location:London, UK

    Posted 10 June 2010 - 03:08 PM

    This is a bump, but your code is special..

    WebBrowser1.Navigate(Textbox1.Text);

    that works fine..

    #3 miinaturvat

    miinaturvat

      miiinaturvat

    • Donors+

    • 927 posts
    • Joined: 09-April 08
    • Gender:Male
    • Location:Dragon Shores!

    Posted 17 June 2010 - 03:56 PM

    pwnt