Version

Setting minimum and maximum values for WebDateTimeEditor

WebDateTimeEditor™ allows you to set a range of date/time values that your end-user can enter into the editor by simply setting the control’s MinValue and MaxValue properties. If an end-user types a date/time more than the maximum date/time, then the editor sets the date/time to the maximum date/time value. Similarly, if an end-user types a date/time value that is less than the minimum date/time value then the editor sets the value back to the minimum value.

You can set the MinValue and MaxValue properties either by using the Microsoft® Visual Studio® Property Window or by using the following code:

In Visual Basic:

'Create the minimum date object
Dim minDate As New DateTime(2004, 1, 1)
'Create the maximum date object
Dim maxDate As New DateTime(2010, 1, 1)
'Assign the minimum date object to the WebDateTimeEditor's MinValue
WebDateTimeEditor1.MinValue = minDate
'Assign the maximum date object to the WebDateTimeEditor's MaxValue
WebDateTimeEditor1.MaxValue = maxDate

In C#:

//Create the minimum date object
DateTime minDate = new DateTime(2004, 1, 1);
//Create the maximum date object
DateTime maxDate = new DateTime(2010, 1, 1);
//Assign the minimum date object to the WebDateTimeEditor's MinValue
WebDateTimeEditor1.MinValue = minDate;
//Assign the maximum date object to the WebDateTimeEditor's MaxValue
WebDateTimeEditor1.MaxValue = maxDate;