Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RequiredFieldValidator
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 3.0
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01462650
Message ID:
01462654
Views:
36
>>I've got a Project in my C# class in which I am using ASP.NET to lay out a Store web page. This is really simple stuff, nothing too complex yet.
>>
>>There are 3 CheckBox controls which represent flags from the USA, France and Texas, which are for sale (This isn't for real). To the right of each CheckBox control, there is a Quantity TextBox control.
>>
>>Below all of this are TextBox controls to gather in the person's name, address, etc., then a Submit button at the bottom of all of this.
>>
>I did not put any validator controls on the CheckBox controls, but did on the Quantity TextBox controls for Range Validation, limiting the buyer to between 0 and 10 flags in each purchase. I then added RequiredFieldValidator controls to the name and address controls. I've set everything. I lastly added a ValidationSummary control after all the other TextBox and CheckBox controls.
>>
>>So, here's my question:
>>
>>If the buyer Checks one Flag and does NOT enter a Quantity in the Quantity TextBoxControl for that Flag, and you hit the Submit button, how do you inform the user that he has left out a quantity? How do you make the RequriedFieldValidator capture the fact that something should have been entered, if the buyer selected a Flag?
>>
>>I know that you can use a RequiredFIeldValidator to make sure something is entered, but what if the user didn't select that particular Flag? Do you have to set up an if condition in the code behind page to capture the CheckBox having been set to TRUE, and then check its Quantity TextBox control? In other words, how flexible are these validation controls?
>>
>>Maybe this isn't as easy as I had thought.
>
>On the server side I think you need to override the Validate() method and skip validation if the checkbox isn't checked. Client side validation isn't quite as simple. This discussion of the validation process in general actually has an example which could probably be adapted to your needs:http://msdn.microsoft.com/en-us/library/aa479045.aspx

This is a great article. I printed it out and am reading it now.
Thanks for the reference.

By the way, I tried uploading a screen shot in JPEG format. It was 91k and should have shown up. So, how do we upload pictures to UT? Okay, I just saw the JPG image. I clicked on it and the JPG file showed up in a separate tabbed Browser. Pretty cool.

Cecil
Previous
Reply
Map
View

Click here to load this message in the networking platform