Hack Forums
[C#] [NOOB QUESTION] Make webbrowser navigate to the text box? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] [NOOB QUESTION] Make webbrowser navigate to the text box? (/showthread.php?tid=5646019)



[NOOB QUESTION] Make webbrowser navigate to the text box? - JAS - Jun 13, 2017

If i didnt explain it well enough in the title. I want to make it so if a user types in lets say www.google.com into a text box and then clicks a button it redirects the web browser to that url... I cant quite fiqure it out.. ( new to c#)


Really want to know this, thanks!


* - Lucifer Morningstar - Jun 13, 2017

Code
private void button1_Click(object sender, EventArgs e)
{
      System.Uri uri = new System.Uri(textBox1.Text);
      webBrowser1.Url = uri;
}



* - JAS - Jun 13, 2017

(Jun 13, 2017 12:54 PM)Lucifer Morningstar Wrote:  
Code
System.Uri uri = new System.Uri(textBox1.Text);
            webBrowser1.Url = uri;

Just as your posted this i worked it out! Thanks anyway.


* - webworms - Jun 13, 2017

If you are using visual studio there is a toolbox item called "WebBrowser" to put into your form. It does everything for you, here is the documentation https://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser(v=vs.110).aspx


* - Lucifer Morningstar - Jun 13, 2017

(Jun 13, 2017 12:55 PM)free707 Wrote:  Just as your posted this i worked it out! Thanks anyway.

Pro-tip: Always check the properties of that element. Usually there is a method.


* - JAS - Jun 13, 2017

(Jun 13, 2017 12:56 PM)Lucifer Morningstar Wrote:  Pro-tip: Always check the properties of that element. Usually there is a method.

Thanks!


* - Ninja - Jun 13, 2017

browser.Navigate(textbox.text)

You should learn how to use Google and how to use MSDN. MSDN has almost every class in C# and VB.net (and F#) documented really well and usually with example code.