Using the AJAX CalendarExtender

BronwenWeeGo.jpgClient wanted a text box they could type a date into but also a calendar control if they didn’t want to type.  So I went with a Textbox, a compareValidator to ensure the entered data was of type Date and the AJAX CalendarExtender the points to the textbox.

Looks something like this:

<asp:TextBox runat="server" ID="calHandoverTextBox"></asp:TextBox>
<asp:CompareValidator ID="calHandoverCompareValidator" runat="server" 
ErrorMessage="Not a valid date" ControlToValidate="calHandoverTextBox" 
Operator="DataTypeCheck" Type="Date" EnableClientScript="False">*</asp:CompareValidator>
<cc1:CalendarExtender runat="server" ID="calHandoverDate" 
TargetControlID="calHandoverTextBox" Format="dd/MM/yyyy" Enabled="True"></cc1:CalendarExtender>