Disabling particular months in Calendarextender

Posted by Anu_dgr8 under JavaScript on 12/26/2011 | Points: 10 | Views : 2468 | Status : [Member] | Replies : 2
I have a Calendarextender inside a Gridview.And i want to disable all the Months of all years except the Current and Previous 2 months of the Current year using Javascript.
Can you tell me how to achieve this ?
Please i need the code.Its urgent.

Thanks and Regards,
Hoosha Boosha



Responses

Posted by: Anu_dgr8 on: 12/26/2011 [Member] Starter | Points: 25

Up
0
Down
I want to achieve this using onClientShown event handler of Calendarextender.

Thanks and Regards,
Hoosha Boosha

Anu_dgr8, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Anu_dgr8 on: 12/27/2011 [Member] Starter | Points: 25

Up
0
Down
My code is as follows:

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><cc1:CalendarExtender ID="TextBox1_CalendarExtender" runat="server" OnClientHidden="onCalendarHidden"  OnClientShown="onCalendarShown" BehaviorID="calendar1"    Enabled="True" TargetControlID="TextBox1"></cc1:CalendarExtender>




function onCalendarShown() { var cal = $find("calendar1"); //Setting the default mode to month cal._switchMode("months", true); //Iterate every month Item and attach click event to it if (cal._monthsBody) { for (var i = 0; i < cal._monthsBody.rows.length; i++) { var row = cal._monthsBody.rows[i]; for (var j = 0; j < row.cells.length; j++) { Sys.UI.DomEvent.addHandler(row.cells[j].firstChild, "click", call); } } } } function onCalendarHidden() { var cal = $find("calendar1"); //Iterate every month Item and remove click event from it if (cal._monthsBody) { for (var i = 0; i < cal._monthsBody.rows.length; i++) { var row = cal._monthsBody.rows[i]; for (var j = 0; j < row.cells.length; j++) { Sys.UI.DomEvent.removeHandler(row.cells[j].firstChild,"click",call); } } } }


function call(eventElement) { var target = eventElement.target; switch (target.mode) { case "month": var cal = $find("calendar1"); cal._visibleDate = target.date; cal.set_selectedDate(target.date); cal._switchMonth(target.date); cal._blur.post(true); cal.raiseDateSelectionChanged(); break; } }




THis code is keeping October,November and Decmber of all years enabled and rest months disabled.I just want to keep October,November and December of the Current year enabled,whereas all the other months of all the years disabled.So please help me guys.

Thanks in advance

Thanks and Regards,
Hoosha Boosha

Anu_dgr8, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response