Preventing RequiredFieldValidator(s) from functioning on a specified portion of a form.

Posted on 2005-05-13
Last Modified: 2008-02-01
I have a page that has two "sections" (ASP.Net panels > > which render as HTML <DIV> blocks, anyway...).

One section is a "Login" section for existing users to login.  The other section is for new users to register (i.e. enter their name and create a password).

I've got required field validators on all my text boxes on the page.  However, there are two buttons:  one that fires the Logon routine, and the other that fires the Register routine.   By necessity, each button's CausesValidation property is TRUE.  What happens is that clicking either one of the buttons fires the validators for the whole page.

What I want is for the Login section's validators to "validate" only when the Login button has been clicked, and vice versa.  I would prefer to do all of the coding server-side in the code-behind and avoid JavaScript on this.

I've searched EE a bit on this already, but could find nothing that I liked (or even really addressed this type of issue).

My thought is that there ought to be a way to make the btnLogon_Click event's code "ignore" the other set of field validators.

The other idea that (I think) I understood from another EE post is to cause the validation to fire manually (make the buttons' CausesValidation property FALSE and raise the validation event elsewhere in the codebehind when I want it).  I'm not too crunk on how that ought to go down...
Question by:mpp1031
    LVL 33

    Accepted Solution

    CausesValidation will not work for you if you must have both forms visible at the same time.

    Good news is, you can achieve what you want with "ValidationGroups"
    Bad news is that it is new in 2.0, so unless you're developing the beta...

    You may want to just use javascript to accomplish this...or, take the validation out of the login, if it's a simple username/password, it's quite simple to just deny the login if they don't enter a field...

    Author Comment

    Thanks, raterus.  That's essentially what I decided to do. ( btnLogin CausesValidation = false ).  Thanks for the help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    737 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

    18 Experts available now in Live!

    Get 1:1 Help Now