K
Keith G Hicks
asp.net 2.0
I'm stumped. I have a page that is used for updating user information. If
the user is logged in and they navigate to that page, then they see text
boxes for UserName, FirstName, Email, Old Password, New Password, Confirm
New Password. Since the user is logged in, I'm populating the data that's
not sensitive like the UserName, FirstName & Email. I'm leaving the Password
boxes blank.
In the database, all the fields above are required. They have to be filled
in when creating a new user on the New User page. On the Edit User page, my
goal is to allow them to change information or leave it blank. If it's
blank, the database is not updated. If it's filled in, then it is.
This is easy enough for the UserName, FirstName & Email text boxes. If the
UserName for example is "Keith" but they blank it out for some reason,
that's ok, it just wont' update. So it's not required (no required field
validator) on this page. So I don't have any required field validators on
those text boxes. I do have a regular expresson one on the UserName so that
it's a minumum lenght and another on the Email so that it's a valid email
address but that's it.
My problem is with the password text boxes. I want the user to be able to
leave them all blank or have to fill them all in. There are no required
field validators on them. I'm trying to handle this in code in the click
event handler of the submit button:
If Not ((Trim(txtOldPwd.Text) = "") And (Trim(txtNewPwd.Text) = "") And
(Trim(txtNewPwdConfirm.Text) = "")) _
And Not ((Trim(txtOldPwd.Text) <> "") And (Trim(txtNewPwd.Text) <> "") And
(Trim(txtNewPwdConfirm.Text) <> "")) Then
lblOldPwdRequired.Visible = True
lblNewPwdRequired.Visible = True
lblNewPwdConfirmRequired.Visible = True
Else
lblOldPwdRequired.Visible = False
lblNewPwdRequired.Visible = False
lblNewPwdConfirmRequired.Visible = False
End If
lblOldPwdRequired and the other "lbl" labels are simply red asterisks.
The code above works as expected but I had to set my submit button's
UseSubmitBehavior property to false. I'm not sure what to do now. I'm sure
the way I'm handlign things is not the best way. I'm looking for some
adivice on this. I only posted the code above so you could see what I'm
trying to accomplish. The validator controls just don't seem to be able to
handle dealing with 3 text boxes in the manner that I need.
Thanks,
Keith
I'm stumped. I have a page that is used for updating user information. If
the user is logged in and they navigate to that page, then they see text
boxes for UserName, FirstName, Email, Old Password, New Password, Confirm
New Password. Since the user is logged in, I'm populating the data that's
not sensitive like the UserName, FirstName & Email. I'm leaving the Password
boxes blank.
In the database, all the fields above are required. They have to be filled
in when creating a new user on the New User page. On the Edit User page, my
goal is to allow them to change information or leave it blank. If it's
blank, the database is not updated. If it's filled in, then it is.
This is easy enough for the UserName, FirstName & Email text boxes. If the
UserName for example is "Keith" but they blank it out for some reason,
that's ok, it just wont' update. So it's not required (no required field
validator) on this page. So I don't have any required field validators on
those text boxes. I do have a regular expresson one on the UserName so that
it's a minumum lenght and another on the Email so that it's a valid email
address but that's it.
My problem is with the password text boxes. I want the user to be able to
leave them all blank or have to fill them all in. There are no required
field validators on them. I'm trying to handle this in code in the click
event handler of the submit button:
If Not ((Trim(txtOldPwd.Text) = "") And (Trim(txtNewPwd.Text) = "") And
(Trim(txtNewPwdConfirm.Text) = "")) _
And Not ((Trim(txtOldPwd.Text) <> "") And (Trim(txtNewPwd.Text) <> "") And
(Trim(txtNewPwdConfirm.Text) <> "")) Then
lblOldPwdRequired.Visible = True
lblNewPwdRequired.Visible = True
lblNewPwdConfirmRequired.Visible = True
Else
lblOldPwdRequired.Visible = False
lblNewPwdRequired.Visible = False
lblNewPwdConfirmRequired.Visible = False
End If
lblOldPwdRequired and the other "lbl" labels are simply red asterisks.
The code above works as expected but I had to set my submit button's
UseSubmitBehavior property to false. I'm not sure what to do now. I'm sure
the way I'm handlign things is not the best way. I'm looking for some
adivice on this. I only posted the code above so you could see what I'm
trying to accomplish. The validator controls just don't seem to be able to
handle dealing with 3 text boxes in the manner that I need.
Thanks,
Keith