C# Web Opening.

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
User avatar
Andrew_b




Socialist

Posts: 4188
Joined: Sat Feb 24, 2007 4:52 pm
Contact:

C# Web Opening.

Post by Andrew_b »

ok i looked in the web tutorial 3 times...might have missed it.
I have a textBox1 and i want to have what ever you type in...it opens it in a web browser (the default browser on the computeR)

I dont know how to do this but and deleted what i had. :P

I had like this (textBox1.ToString); or something..and yes i know thats only the last part.
User avatar
LuxuriousMeat





Posts: 824
Joined: Thu Nov 03, 2005 6:43 pm
Location: zzzzzzzzzzzzzzzz
Contact:

Post by LuxuriousMeat »

Add this to the top of your code file:

Code: Select all

using System.Diagnostics;
Then use this to open the link in the text box.

Code: Select all

if (Uri.IsWellFormedUriString(textBox1.Text, UriKind.Absolute))
    Process.Start(textBox1.Text);
Image
User avatar
Andrew_b




Socialist

Posts: 4188
Joined: Sat Feb 24, 2007 4:52 pm
Contact:

Post by Andrew_b »

is there a way so it doesnt need the http://www. ?
User avatar
Tural




Conceptionist Acolyte Bloodhound Recreator
Socialist Connoisseur Droplet Scorched Earth
Grunge

Posts: 15628
Joined: Thu Jun 16, 2005 3:44 pm
Location: Lincoln, NE
Contact:

Post by Tural »

You could always just check if the string has it present, and if not, add it.
User avatar
LuxuriousMeat





Posts: 824
Joined: Thu Nov 03, 2005 6:43 pm
Location: zzzzzzzzzzzzzzzz
Contact:

Post by LuxuriousMeat »

Or just remove the if i put there. The if just checks if the string in the text box is a valid URL.
Image
User avatar
Andrew_b




Socialist

Posts: 4188
Joined: Sat Feb 24, 2007 4:52 pm
Contact:

Post by Andrew_b »

didnt think of deleting the if. Thanks.
Post Reply