This tutorial was created with Microsoft’s ASP.NET AJAX Extensions for VS.NET 2005, which can be downloaded here.

This brief article will show how easy it is to make the calendar control more dynamic and usable, by implementing AJAX to input the selected date into a textbox for submission without using PostBack.

First, we create an ‘AJAX-Enabled Web Site’ in Visual Studio .NET
Which will give us our ScriptManager tag, and also the AJAX assembly references in the Web.config:

We create a TextBox control and a Calendar control:

Note that the Calendar has a OnSelectionChanged attribute, and that both the controls are within the UpdatePanel tags. This will ensure that these controls are refreshed when the trigger is activated.

The only code we need is below. This is executed when the selection of the calendar control is changed (when the user clicks on a new date). When this happens, the method PutDateInBox is called and the date is input into the textbox control, from the calendar control.