Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to know whether a hyperlink is entered in a textbox?

0 views
Skip to first unread message

Luc

unread,
Nov 19, 2009, 5:17:47 PM11/19/09
to
Hi,

I want to know whether a hyperlink is enterd in a textbox. An user enters
this string into a textbox: <a href='http://...'>click</a>
In order to know that, i tried to know whether the string "click" was typed
in the textbox.

This is what i did:
<asp:TextBox ID="TextBox1" TextMode="MultiLine"
runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim hl As String = "click"
Dim x As Integer
Dim txt as string = TextBox1.text

x = txt.IndexOf(hl)
if x>0 then
response.write("yes")
else
response.write("yes")
end if

End Using

But this gives 0 .

Is there a way to determine whether "click" is entered, or is there a way to
determine whether a hyperlink is entered in the textbox?
Thanks
Luc


Family Tree Mike

unread,
Nov 19, 2009, 5:49:22 PM11/19/09
to

Your intended code works for me. I say intended because you have a "End
Using" with no using statement, and you write "Yes" in both clauses of
the test.

By the way, you must be overriding the setting of Page.ValidateRequest
in order to accept the url in a text box.

If you are testing for a url though, why depend on the user including
the word "click"?

--
Mike

Luc

unread,
Nov 20, 2009, 12:43:03 PM11/20/09
to
Thanks

"Family Tree Mike" <FamilyT...@ThisOldHouse.com> schreef in bericht
news:O7OkJqWa...@TK2MSFTNGP02.phx.gbl...

Alexey Smirnov

unread,
Nov 20, 2009, 6:25:22 PM11/20/09
to

It depends on what you finally need to do. For instance, beside the
code you can try to use client-side script, or a CompareValidator
control to validate against a specific value...

0 new messages