URL Validation in Windows Forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How to validate a URL typed in a textbox in the windows forms using C#
language.
I need complete code.

Thanks in advance.

-Shankar
 
shankar,

What kind of validation are you doing? Do you want to validate the
syntax of the URL? If that is the case then pass the string to the
constructor of the Uri class and it should throw an exception if the url
syntax is not valid.

If you want to validate that the resource exists, then you will need to
call the static Create method on the WebRequest class, passing the URI and
trying to connect to the resource.

Hope this helps.
 
Back
Top