This tutorial was created with Microsoft’s ASP.NET AJAX Extensions for Visual Studio.NET 2010.

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:

Start by adding an AJAX ToolScript Manager, to your web page.

We then 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.

Thank you for reading our tutorial on AJAX Controls, we aim to provide the best AJAX tutorials. Learning AJAX in ASP.NET is easy and we hope you are getting your hands dirty by trying different things and coming up with your own ideas. If you have any questions or concerns, please feel free to suggest a tutorial or you can comment below in the comments section.

Download Source Files