problems with indexOf

  • Thread starter Thread starter gh0st54
  • Start date Start date
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
 
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
 
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)
 
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
 
Back
Top