Ajax CalendarExtender and manually change date in the associated TextBox control

The Scenario:
Select a date from the CalendarExtender control & that date gets visible in the associated Textbox.
Now alter the date in the textbox manually. If the Enter key is not pressed, next time when the CalendarExtender gets visible , it would still show the wrong date (earlier selected date) as the selected date.
The Solution:
Refresh the “CalendarExtender control” client-side, using show() function, at the TextBox’s “onchange” event.
Here’s the complete code
function abc() {
function xyz() {
var a = document.getElementById(“TextBox1”);
var b = document.getElementById(“TextBox2”);
if (a.value != “”) {
b.value = $find(“a2”).get_selectedDate();


<asp:ScriptManager ID=”ScriptManager1″ runat=”server”></asp:ScriptManager>
<asp:TextBox ID=”TextBox1″ runat=”server” AutoPostBack=”false” OnChange=”abc();” ></asp:TextBox>
<ajaxToolkit:CalendarExtender ID=”CalendarExtender1″ BehaviorID=”a2″   runat=”server”  EnableViewState=”false” OnClientDateSelectionChanged=”xyz” TargetControlID=”TextBox1″ ></ajaxToolkit:CalendarExtender>
<br />
<asp:TextBox ID=”TextBox2″ runat=”server”  ></asp:TextBox>
This entry was posted in AJAXToolKit and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s