Link to home
Start Free TrialLog in
Avatar of allanmark
allanmark

asked on

Validating Login control fields

Greetings all

I have a Login control on a page and a button, called "btnForgotPassW. When the user clicks the ForgottenPassW button, I want to ensure that he has at leat entered his userame in the appropriate field.

How do I do this?

In advance, thanks!

   allanmark
Avatar of burakiewicz
burakiewicz
Flag of United States of America image

Login1 == name of your login control
protected void btnForgotPassW_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Login1.UserName))
            {
                //no username
            }
            else
            {
                //has username
            }
        }
ASKER CERTIFIED SOLUTION
Avatar of kGenius
kGenius
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of allanmark
allanmark

ASKER

Looks good!

How do I only validate the username field on the Forgot button click?

The username and password field valdiators are assigned to Login1. I could change the password fieldvalidator's group to Login2 and then set the Forgot button to Login1 -- problem  -- as far as I can tell, you can only have one validation group attached to a control, so the LogIn button would ahve to be Login11 or Login2, but NOT both
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excellent answers!!  Many thanks!!!