Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Validating Login control fields

Posted on 2008-06-20
5
Medium Priority
?
181 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 1000 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 1000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

885 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