I was solving the following problem: There are two buttons (B1 and B2) on a form and two fields (F1 and F2). B1 should trigger the validation of F1, while B2 makes both F1 and F2 validated.
The concept of validation groups as introduced in .NET 2.0 is well prepared for two logically independent forms of one page, but is quite not ready for above described situations (that are not so rare I think).
I rejected the idea of triggering the validation manually on button click. I wanted to follow the common pattern of validation as much as possible. I'm afraid you cannot share validators among several validation groups nor you can attach several validation groups to a single button. (The latter would be much preferred.) I introduced two validation groups, and there is a duplication of validators for F1 in order to make them included in both validation groups. This duplication is pretty systematic (only ValidationGroup
property varies) and recognisable at first sight, but still it is a pitty to have it there.
Wednesday, January 30, 2008
Overlapping Validation Groups and Duplication of Validators
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment