Does anyone know how to change the selected date in the calendar through client side javascript? I want to verify the date selected is today or later and if it is not then I want to reset the date in the calendar to today's date.
Thanks,
Eric
I don't think you can do that without a postback, you can put that calendar between an UpdatePanel and will look like is client side. Otherwise you may have to use another control. There are plenty on the webI finally figured it out. The ajax toolkit calendar control, and some of the otehr controols, has a BehaviorID property which can be assigned any value I guess. I called it 'CalBehavior1'. Once that was done, I looked in the JS source file for the control in the source code of the AjaxControlToolKit. In that JS file, I saw the various methods and properties that are exposed on the client side. I have an OnClientDateSelectionChanged event handler attched to the control, so everytime the user selects a date I have some JS code that verifies the selected date is today or later. To set the date in the calender to today, I do the following:
$find(
'CalBehavior1').set_selectedDate($find('CalBehavior1').get_todaysDate());
I finally figured it out while looking at the rounded corners example in the sample website of the Ajax Control Toolkit. The Ajax Toolkit Calendar control, and some of the other controls, has a BehaviorID property which can be assigned any value I guess. I called it 'CalBehavior1'. Once that was done, I looked in the JS source file for the control in the source code of the AjaxControlToolKit. In that JS file, I saw the various methods and properties that are exposed on the client side. I have an OnClientDateSelectionChanged event handler attched to the control, so everytime the user selects a date I have some JS code that verifies the selected date is today or later. To set the date in the calender to today, I do the following:
$find('CalBehavior1').set_selectedDate($find('CalBehavior1').get_todaysDate());
Yea!!!
Eric
No comments:
Post a Comment