Using .NET validators to do field dependencies

Discussion in 'ASP .Net' started by lorenzon@gmail.com, Feb 9, 2007.

  1. Guest

    I have a relatively simple case where I have a form with two fields
    (call them A and B) which need to be enabled mutually exclusively
    depending on the state of a drop down. So if drop down is "A" then
    field A is populateable and if B then B.

    This would be relatively simple to do with a CustomValidator I
    imagine, but assuming I just wanted a serverside check, can anyone
    think of a way of using say the CompareValidator or something to do
    this check, even extending might be an option if it's less work than
    writing the whole thing from scratch with a customvalidator..
     
    , Feb 9, 2007
    #1
    1. Advertising

  2. What's wrong with simply using the .Enabled property of fields A and B during
    the SelectedIndexChanged event of the drop-down list? Better yet, use
    javascript to enable/disable the fields, so its all done client-side? Either
    way, this doesn't sound like a task for the CustomValidator. The
    CustomValidator control is basically a label that turns on/off based on
    conditional logic you set up in the control's event.

    "" wrote:

    > I have a relatively simple case where I have a form with two fields
    > (call them A and B) which need to be enabled mutually exclusively
    > depending on the state of a drop down. So if drop down is "A" then
    > field A is populateable and if B then B.
    >
    > This would be relatively simple to do with a CustomValidator I
    > imagine, but assuming I just wanted a serverside check, can anyone
    > think of a way of using say the CompareValidator or something to do
    > this check, even extending might be an option if it's less work than
    > writing the whole thing from scratch with a customvalidator..
    >
    >
     
    =?Utf-8?B?S2VpdGg=?=, Feb 9, 2007
    #2
    1. Advertising

  3. Guest

    Well a couple of reasons, firstly the validation rules are kept in a
    business object that has no knowledge of clientside environments,
    secondly I'm validating controls in an auto generated form in a grid
    and don't want to have to explicitly hack in my own form to make this
    work.

    I've got everything sorted out except the rather crucial step of
    finding a way to access other controls' values during the validation
    (in the servervalidation delegate). There doesn't seem to be any way
    to do that.
     
    , Feb 9, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric Sabine

    Required field validators

    Eric Sabine, Nov 19, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    317
    Stefano Mostarda
    Nov 19, 2003
  2. Rob H
    Replies:
    4
    Views:
    440
    sandeep
    Jan 7, 2004
  3. Ratman
    Replies:
    0
    Views:
    665
    Ratman
    Sep 14, 2004
  4. Sound
    Replies:
    2
    Views:
    454
    Randy Webb
    Sep 28, 2006
  5. jr
    Replies:
    3
    Views:
    426
Loading...

Share This Page