Solved

Validating Login control fields

Posted on 2008-06-20
5
174 Views
Last Modified: 2013-12-16
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
0
Comment
Question by:allanmark
  • 2
  • 2
5 Comments
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21832708
Login1 == name of your login control
protected void btnForgotPassW_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Login1.UserName))
            {
                //no username
            }
            else
            {
                //has username
            }
        }
0
 
LVL 7

Accepted Solution

by:
kGenius earned 250 total points
ID: 21832731
You can use the LayoutTemplate in your login control. Then add the RequiredFieldValidator for your username textbox.
This method is discribed in:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.login.layouttemplate.aspx

HTH,
Karl
0
 

Author Comment

by:allanmark
ID: 21833779
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
0
 
LVL 7

Assisted Solution

by:kGenius
kGenius earned 250 total points
ID: 21835054
You can use a javascript that checks the value of the input field username.
When empty the form may not be submitted.
I think this thread on asp.net can help you out:
http://forums.asp.net/p/1058284/1512529.aspx
0
 

Author Closing Comment

by:allanmark
ID: 31469169
Excellent answers!!  Many thanks!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now