Solved

Validating Login control fields

Posted on 2008-06-20
5
179 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 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