Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Using .NET validators to do field dependencies

Reply
Thread Tools

Using .NET validators to do field dependencies

 
 
lorenzon@gmail.com
Guest
Posts: n/a
 
      02-09-2007
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..

 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2VpdGg=?=
Guest
Posts: n/a
 
      02-09-2007
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..
>
>

 
Reply With Quote
 
 
 
 
lorenzon@gmail.com
Guest
Posts: n/a
 
      02-09-2007
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript validation for a not required field, field is onlyrequired if another field has a value jr Javascript 3 07-08-2010 10:33 AM
1.Enter space bar for field names and save the field.The field shoud not get saved and an alert should be there as"Space bars are not allowed" Sound Javascript 2 09-28-2006 02:43 PM
Regular Expression validators NOT working, Required Field validators ARE working Ratman ASP .Net 0 09-14-2004 09:36 PM
Required Field Validators and Response.Redirect Rob H ASP .Net 4 01-07-2004 04:44 AM
Required field validators Eric Sabine ASP .Net 1 11-19-2003 11:18 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57