Validation on User Controls

liunx

Guest
I built a user control that contains name, address, city, state, zip information. I use one for Billing and one for Shipping on the same page. Right now, the validation fires on both if only one of the fields is null. For instance, if Billing and Shipping's address field is required and Shipping's address field was filled in and Billing's address field was not, it still fires both validation controls.

How would I go about creating a validation control that would be independent of each instance of the same control added to a .aspx page?sounds like u are using vb.net instead of c#.net?
vb.net auto wire all ur validators, so at your submit button (under design view), go to that button's property and choose validate control to false (forget the exact name, but u'll found it)

hope that helpsActually, I'm using C#. Either way, I'll settle for VB or C# examples. I have one user control, but it's added to a page twice, once for Shipping information and once for Billing information. What I want to do is have unique validation for each so it flags (Please provide a 'shipping address'.) and (Please provide a 'billing address'.) Right now, it looks like I might have to take the user controls out and just drop the textboxes for Shipping and then drop textboxes in for Billing.comn8u,
how solid is your OOP skill? you can make a interface web user control, and have 2 other controls (shipping and billing) implement from it.

or, have either 1 of the control is a parent of another, and method overrides toString() so it'll print "Please provide billing address" or "please provide shipping address" based on the object you are calling.

if you are not comfortable with OOP, then just make 2 user controls and copy a brunch of code to it :)
 
Back
Top