Check if a textbox contains characters or a string




If you want to check a textbox to see if it contains a character or a certain string, follow the below format.:
  1. If Textbox1.Text.Contains("http://") Then
  2.  Response.Write("Success")
  3. End If
You could place whatever code you want in place of Response.Write, to do what ever you want. A variation of the above could be handy as a basic anti-spam post filter. Something like below:
  1. If Textbox1.Text.Contains("http://") OR Textbox1.Text.Contains("www.") Then
  2.  Response.Write("Success")
  3. End If
If you wanted to check a string for a character or a string, do the below:
  1. Dim str As String = Textbox1.Text
  2. If str.Contains("http://") Then
  3.  Response.Write("Success")
  4. End If


No one has said that they like article yet, be the first and click here (0)
Send a link to this page via email Send a link to this page