I’ve been tasked with making some fields such as textboxes in the edit template of a FormView to be required fields. This is for an ASP.NET 4 web app. I am testing the use of ASP.NET RequiredFieldValidators controls for this. This is a simpler task than I thought. The documentation only directly refers to examples that use new entry or insert mode fields. You have to read between the lines to understand that this control can be used in fields that contain values without requiring an edit action from the user. The reason is this control only compares the field’s value to its initial value property which by default is an empty string. In testing I found that as long as the field has a non-empty value it won’t interrupt form submission: as long as this user doesn’t make the field blank, the form fields can be submitted without problems. If there are circumstances where fields are intentionally blanked on use, one can change the initial value property of the control to some other value to trigger a required field entry validation.

One can also combine this control with the Ajax Control Tool Kit controls too. More on this later.

Leave a Reply

Your email address will not be published. Required fields are marked *