|
ASP.NET Validation Package DemosThe following set of ASP.NET Validation Package demos contain similarities that will be dealt with here rather than on the demo pages themselves. Firstly, the XML snippet below has been taken from the appSettings section of this site's web.config file: <add key="validatorSummaryTitle" value="The follows errors occurred on the page:" />
<add key="validatorInitialHighlightClass" value="validatorInitial" />
<add key="validatorHighlightClass" value="validatorError" />
<add key="validatorDefaultHighlightElement" value="<div[className=formInput]>" />
<add key="validatorUseTicks" value="true" />
<add key="validatorJavascriptPath" value="/Controls/Validation/" />
<add key="validatorTickPath" value="/images/tick.gif" />
<add key="validatorCrossPath" value="/images/cross.gif" />
<add key="validatorDimCrossPath" value="/images/crossdim.gif" />
Each of the properties listed above can also be controlled on the Validator control's tag itself as well as programmatically. Any properties found on the tag override those found in the web.config file, and any properties overridden programmatically (for example in the Page_Load method) override those found on the Validator control's tag. You'll notice that the client-side validation on each of these demos will highlight the area surrounding the field that is being validated when the validation for that field fails. The styles for this highlight are controlled by the InitialHighlightClass and the HighlightClass properties. When the field passes validation, the class on the "highlight element" returns to the class that the element had upon page load. In these demos, the HTML element on which the validation highlight takes place is marked by the signature <div[className=formInput]> (controlled through the property DefaultHighlightElement). This tells the validator to look for the next closest ansestor div that is higher in the HTML hierarchy than the field being validated and that has the initial class name formInput. In these demos, the highlight element is the one immediately preceeding the validated field. The initial highlight class on each of the demos contains a big red asterisk. This is applied to the highlight element after the page has loaded when the field that it represents fails its initial validation (except during a postback). So in these demos, the asterisk does not strictly denote a required field. Once the field passes validation, the highlight field returns to its default state and the asterisk disappears. This probably isn't desirable in most situations. If in your own forms you would like such a required field marker to sit permanently beside the validated field, you'll have to simply place it there in the HTML or in the default class for the highlight element. Note that required field markers are not natively supported by the ASP.NET Validation Package. Demo 1 - Non-server forms Demo 2 - Server forms using server controls Demo 3 - Multiple non-ASP.NET server forms Demo 4 - Multiple validation groups within an ASP.NET server form Demo 5 - Customised validation summary Demo 6 - Mixed client-side and server-side only valdation Demo 7 - Most validators Demo 8 - More validators Demo 9 - Individual client-side disabling © 2002 - 2008 Copyright, Disclaimer and Privacy Statement |
||||||