A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.

Required Field Validator for Form Fields in Edit mode

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

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>