problems with indexOf

G

gh0st54

hi

im'trying to validate that someone registering a new user does not
name im 'admin' or something like that

i'm using

bool bInvalidUsername = false;

bInvalidUsername = this.txtUserName.Text.ToLower().IndexOf("admin")>
-1 ?true:false;

but i always get
error: 'this.txtUserName.Text.ToLower' does not exist or a variant of
the message

?this.txtUserName.Text
"admin1234"
?this.txtUserName.Text.ToLower().IndexOf("admin")
error: 'this.txtUserName.Text.ToLower' does not exist
?this.txtUserName.Text.IndexOf("admin")
error: 'this.txtUserName.Text.IndexOf' does not exist

what am i doing wrong thanks
 
K

Karl Seguin

That's a weird one. What version of the framework are you using? Are these
run-time or compile-time errors? I don't see anything inherently wrong with
what you are doing...

Karl
 
B

bruce barker

note: the debugger does not support string methods.

if you get these messages are runtime, then it means this.txtUserName.Text
is not a string. try:

bool bInvalidUsername =
this.txtUserName.Text.ToString().ToLower().IndexOf("admin") > -1 ? true :
false;

-- bruce (sqlwork.com)
 
G

gh0st54

HI

thanks for the reply

they are run-time in the immediate window in debug.

i found my problem which was not caused by the indexOf

but it's still weird that you get the error
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top