Jump to content

  •  

  • iBotModz CBox


    Lakar

    Member Since 01 Nov 2008
    Offline Last Active Oct 11 2009 02:59 AM
    -----

    #88250 (C#)Navigate to URL

    Posted by Lakar on 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