Return to the menu   Select another DES Module

Demonstrates validators applied to the TimeOfDayTextBox.

Demonstrates validators applied to the TimeOfDayTextBox.


Controls

These two TimeOfDayTextBoxes are associated with numerous validators.

These examples use the TimeOfDayTextBox but also work with DurationTextBox.

Start Time:
...

End Time:



DataTypeCheckValidator

DataTypeCheckValidator on both textboxes (always add these validators. Do not assume client-side formatting features of the TimeOfDayTextBox will protect you)

Validation not invoked yet on Start Time Validation not invoked yet on End Time

CompareTwoFieldsValidator

CompareTwoFieldsValidator where Start Time is less than End Time

Validation not invoked yet

CompareToValueValidator

CompareToValueValidator where the time must be greater than 10 AM.

Validation not invoked yet

RangeValidator

RangeValidator where Start time must be between 10 AM and 4 PM.

Validation not invoked yet

UnselectableTimesValidator

UnselectableTimesValidator uses the values assigned to the TimeOfDayTextBox.PopupTimePicker to identify unselectable times. All times not in the TimePicker's Items collection are unselectable.
Validation not invoked yet

DifferenceValidator

DifferenceValidator where the two times must be more than 5 hours apart. Uses the OneEquals property to define that the DifferenceValue is in Hours.
Validation not invoked yet

RequiredTextValidator

RequiredTextValidator on Start Time

Validation not invoked yet

Source Code (C#)

<script runat="server">
protected void Page_Load(object sender, EventArgs e) { // the RangeValidator uses these two properties if assigned StartTimeOfDay.MinTime = new TimeSpan(10, 0, 0); StartTimeOfDay.MaxTime = new TimeSpan(16, 0, 0); CompareToValueValidator1.ValueToCompareAsNative = new TimeSpan(10, 0, 0); DifferenceValidator1.DataBind(); } protected void Button1_Click(object sender, EventArgs e) { if (PeterBlum.DES.Globals.WebFormDirector.IsValid) { // save the data here } }
</script> <p>These two TimeOfDayTextBoxes are associated with numerous validators.</p> <p><i>These examples use the TimeOfDayTextBox but also work with DurationTextBox.</i></p> Start Time: <des:TimeOfDayTextBox ID="StartTimeOfDay" runat="server"> <PopupTimePicker Activate="true" AutoFillStartTime="9:0:0" AutoFillEndTime="18:0:0" AutoFillIncrement="60" /> </des:TimeOfDayTextBox><br/> End Time: <des:TimeOfDayTextBox ID="EndTimeOfDay" runat="server"> </des:TimeOfDayTextBox><br/> <br/> <des:Button ID="Button1" runat="server" Text="Validation and Submit" OnClick="Button1_Click" /> <br/> <br/> <h2>DataTypeCheckValidator</h2> <a href="../../Validation/Validators/Controls/DataTypeCheckValidator.aspx" class="ControlClass">DataTypeCheckValidator</a> on both textboxes (always add these validators. Do not assume client-side formatting features of the TimeOfDayTextBox will protect you)<br/><br/> <des:DataTypeCheckValidator ID="DataTypeCheckValidator1" runat="server" ControlIDToEvaluate="StartTimeOfDay" ErrorMessage="Invalid entry in Start Time" NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet on Start Time"> </des:DataTypeCheckValidator> <des:DataTypeCheckValidator ID="DataTypeCheckValidator2" runat="server" ControlIDToEvaluate="EndTimeOfDay" ErrorMessage="Invalid entry in End Time" NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet on End Time"> </des:DataTypeCheckValidator> <br/> <br/> <h2>CompareTwoFieldsValidator</h2> <a href="../../Validation/Validators/Controls/CompareTwoFieldsValidator.aspx" class="ControlClass">CompareTwoFieldsValidator</a> where Start Time is less than End Time<br/><br/> <des:CompareTwoFieldsValidator ID="CompareTwoFieldsValidator1" runat="server" SecondControlIDToEvaluate="EndTimeOfDay" ControlIDToEvaluate="StartTimeOfDay" ErrorMessage="Make Start < End" Operator="LessThan" NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet" > </des:CompareTwoFieldsValidator> <br/> <br/> <h2>CompareToValueValidator</h2> <a href="../../Validation/Validators/Controls/CompareToValueValidator.aspx" class="ControlClass">CompareToValueValidator</a> where the time must be greater than 10 AM.<br/><br/> <des:CompareToValueValidator ID="CompareToValueValidator1" runat="server" ControlIDToEvaluate="StartTimeOfDay" ErrorMessage="Make Start greater than {VALUETOCOMPARE}" Operator="GreaterThan" NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet"> </des:CompareToValueValidator> <br/> <h2>RangeValidator</h2> <a href="../../Validation/Validators/Controls/RangeValidator.aspx" class="ControlClass">RangeValidator</a> where Start time must be between 10 AM and 4 PM.<br/><br/> <des:RangeValidator ID="RangeValidator1" runat="server" ControlIDToEvaluate="StartTimeOfDay" ErrorMessage="Start Time must be between {MINIMUM} and {MAXIMUM}" NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet"> </des:RangeValidator> <br/> <br/> <h2>UnselectableTimesValidator</h2> UnselectableTimesValidator uses the values assigned to the <span class="PropertyName">TimeOfDayTextBox.PopupTimePicker</span> to identify unselectable times. All times not in the TimePicker's Items collection are unselectable.<br/> <des:UnselectableTimesValidator ID="UnselectableTimesValidator1" runat="server" ControlIDToEvaluate="StartTimeOfDay" ErrorMessage="That time is not available" NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet"> </des:UnselectableTimesValidator> <br/> <br/> <h2>DifferenceValidator</h2> <a href="../../Validation/Validators/Controls/DifferenceValidator.aspx" class="ControlClass">DifferenceValidator</a> where the two times must be more than 5 hours apart. Uses the <span class="PropertyName">OneEquals</span> property to define that the <span class="PropertyName">DifferenceValue</span> is in Hours.<br/> <des:DifferenceValidator ID="DifferenceValidator1" runat="server" SecondControlIDToEvaluate="EndTimeOfDay" ControlIDToEvaluate="StartTimeOfDay" DifferenceValue="5" OneEquals="Hour" ErrorMessage="More than {DIFFERENCEVALUE} hours difference" Operator="GreaterThan" NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet"> </des:DifferenceValidator> <br/> <br/> <h2>RequiredTextValidator</h2> <a href="../../Validation/Validators/Controls/RequiredTextValidator.aspx" class="ControlClass">RequiredTextValidator</a> on Start Time<br/><br/> <des:RequiredTextValidator ID="RequiredTextValidator1" runat="server" ControlIDToEvaluate="StartTimeOfDay" ErrorMessage="Requires an entry" NoErrorFormatter-Mode="FirstTime" NoErrorFormatter-Text="Validation not invoked yet" > </des:RequiredTextValidator>

Return to the menu   Select another DES Module