473,657 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple Validators against a control

I'm trying to use the ASP.NET validators to check some client-side business
rules. I've got two ASP TextBox controls (call them tbxYear1 and tbxYear2)
used to enter a range of years. I've got a couple things I need to check:

1) tbxYear1 and tbxYear2 are both optional, but if values are entered they
have to integers and non-negative
2) if values are entered for both tbxYear1 and tbxYear2 then tbxYear1 must
be less than tbxYear2

It looks like I can use a couple of the validator controls to, collectively,
make these checks. What I'd like to know is if there is a way to "short
circuit" the comparison sequences that multiple validator controls seem to
go through? For instance, if rule #1 is violated, then it probably doesn't
make sense to warn the user that rule #2 has also been violated.

I'm wondering if a CustomValidator control is the way to go here, but I'm
note sure. I assume this type of scenario happens all the time, so I'm
looking for a best practice.

Thanks!
Nov 19 '05 #1
1 2111
There are some cases where shortcircuiting happens:
1. If the textbox is blank, only the RequiredFieldVa lidator reports an
error.
2. If the Type property demands Date or a number and the value is not the
format for that type, its disabled.

Once the field has text and matches the type, all validators will report
errors. You are correct that one solution is to rewrite the validator using
a CustomValidator . Another choice is to use a third party validator that can
handle this. I am the author of "Profession al Validation And More"
(http://www.peterblum.com/vam/home.aspx). It replaces Microsoft's validators
with 22 greatly improved validators. For example, all of the validators can
have a rule that disables them. For example, you need a RangeValidator and
CompareValidato r and both can report an error. In my system, you can assign
have the CompareValidato r disable itself if the value is out of range (as
the RangeValidator will be reporting an error). You can also combine the
rules of several validators under one error message using my
MultiConditionV alidator.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"epigram" <no****@spammy. com> wrote in message
news:1112722640 .c6d135992fd337 6400fcd8022f29e 6c4@bubbanews.. .
I'm trying to use the ASP.NET validators to check some client-side
business rules. I've got two ASP TextBox controls (call them tbxYear1 and
tbxYear2) used to enter a range of years. I've got a couple things I need
to check:

1) tbxYear1 and tbxYear2 are both optional, but if values are entered they
have to integers and non-negative
2) if values are entered for both tbxYear1 and tbxYear2 then tbxYear1 must
be less than tbxYear2

It looks like I can use a couple of the validator controls to,
collectively, make these checks. What I'd like to know is if there is a
way to "short circuit" the comparison sequences that multiple validator
controls seem to go through? For instance, if rule #1 is violated, then
it probably doesn't make sense to warn the user that rule #2 has also been
violated.

I'm wondering if a CustomValidator control is the way to go here, but I'm
note sure. I assume this type of scenario happens all the time, so I'm
looking for a best practice.

Thanks!

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2017
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These controls and validators are then added to a table for display to the user. This code did seem to work originally, but now does not amd I am stumped as to why. There have been some code changes, but not to the methods below and I have pretty much...
0
1909
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These controls and validators are then added to a table for display to the user. This code did seem to work originally, but now does not amd I am stumped as to why. There have been some code changes, but not to the methods below and I have pretty much...
2
2114
by: Avad | last post by:
I have a following screen. The login is a "user control" with validations controls in it. This side I have address book in which "name" is required field. But when I click on "add new user" the validations controls of the login also gets fired. I want that if "add new user" button is clicked it should only fire validation control assign for name field and not login validations and if I click "login" button it should fire login validation...
4
1729
by: Samuel Hon | last post by:
Hi I'm building a custom control which basically takes data from the user and then submits it. I would use the validator controls but if I understand correctly (I've been working with .Net for 2 weeks) you cant 'embed' them in the custom controls. Someone correct me if I'm wrong (and please point to an example :) ) So, to get around this, I'm using Javascript. In my control, I'm doing
6
1620
by: Mark | last post by:
We have Validators embedded in an asp table server control. The table server control is necessary and cannot be replaced. We want to apply CSS formatting to the validators, but the validators have a default RED font that appears to be difficult to remove. We could hard code in a blank font color into the .aspx html for each validator, but that would defeat the purpose of the CSS. Is there a way to change the default RED color of...
1
3910
by: Ken Varn | last post by:
If a page has multiple ValidationSummary controls, how does it distinguish which ValidationControls are associated with which ValidationSummary controls? The reason I am asking this is that I want to display a Message Box for the validation message on my Validation controls. My validation control is embedded within a custom server control. If my custom server control adds a ValidationSummary control, I am afraid that it may conflict...
3
1935
by: rgparkins | last post by:
Hi I am currently having problems with Validators in a user control. I am creating a wizard sign-up process which have the allocated step (hyperlinks" at the top of the page. A user can also click next/previous. Dependant on the current step in the sign-up process I am loading a new user control as I dont want to have 7-8 pages, just one page and load the control dynamically. All is sweet at the moment apart from the validation...
4
2590
by: Brybot | last post by:
I have a form that i've split up into multiple asp:panels, each panel has a number of validators which work correctly. At on the last panel, i want to commit the data collected to a database. I figured since all the panel data is still being sent through the postbacks, instead of using Sessions, or HttpContext, I could just take the values from the textboxes. This all works fine, except for security. I realized that I could inject...
2
1116
by: Jordan S. | last post by:
I'm experimenting with dynamically inserting custom composite Web server controls onto a page. For testing purposes I have two custom composite Web server controls that each have a couple of TextBox controls and a "submit" button, as well as required field validators for each of the textboxes. What I'm finding is that when both of these Web server controls appearon the page, clicking on the "submit" button of either of the controls causes...
0
8740
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7352
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.