Hello,
I wanted to display a date pickerwhich disply two month at atime, Eg June-2010 & July-2010 For that I used two calendar extender controls tha target id of both the controls are pointing to one text box. I am able to position the two calendars adjacent. Onclientshown event I captured the Next and Previous button events of both calendars. My aim is if i click the Next/Prev button of any calendar , the Month and Year of the other calandar too also to be shfited accordigly. It is working fine for the first clcik only. After loading the form If i click Next/Prev button of one calendar the month and year of the other calendar will get changed. But thereafter any no other button click will not work. The sample code is shown below.
Javascript Part
function setEvents(sender,args)
{
//Find all the cell DIVs in the Calendar's container
var cal = sender;
var CalId= sender._body.id.substr(0,sender._body.id.length-5);
var ifind=false;
var dayDIVs = sender.container.getElementsByTagName("DIV");
for (i = 0; i < dayDIVs.length; i++) {
//Add you own code here...
if (dayDIVs[i].className == "ajax_calendar_prev")
{
$addHandler(dayDIVs[i], "click", PrevClicked);
ifind=true;}
if (ifind==true)
break;
}
}
function setEvents1(sender,args)
{
//Find all the cell DIVs in the Calendar's container
var cal = sender;
var CalId= sender._body.id.substr(0,sender._body.id.length-5);
var ifind=false;
var dayDIVs = sender._container.getElementsByTagName("DIV");
for (i = 0; i < dayDIVs.length; i++) {
//Add you own code here...
if (dayDIVs[i].className == "ajax__calendar_next")
{ $addHandler(dayDIVs[i], "click", NextClicked);
ifind=true;}
if (ifind==true)
break;
}
//setEvents($find(objCalMain + '1'),args);
}
function PrevClicked() { var cal =$find(objCalMain + '1'); var stDate;
if (cal._visibleDate==null) { stDate= fnDateAdd(cal._selectedDate,-1); } else { stDate= fnDateAdd(cal._visibleDate,-1); }
// alert(stDate);
var cal1 =$find(objCalMain); cal1.set_selectedDate(stDate); cal1.raisePropertyChanged("selectedDate"); // cal1._textbox.set_Value(""); alert(stDate); alert(cal1._visibleDate); //return false;
} function NextClicked() { var cal =$find(objCalMain); var stDate;
if (cal._visibleDate==null) stDate= fnDateAdd(cal._selectedDate,-1); else stDate= fnDateAdd(cal._visibleDate,-1);
var cal1 =$find(objCalMain+'1'); cal1.set_selectedDate(stDate); cal1._textbox.set_Value(""); //cal1.raisePropertyChanged("selectedDate"); //cal1._switchMonth(target.date);
//alert(cal1._visibleDate); } function fnDateAdd(objval,fact) { var i; var yVal,mVal,dVal;
yVal=objval.getFullYear(); mVal=objval.getMonth()+1; dVal=objval.getDate(); mVal=mVal+fact; if (mVal>12){ mVal=1; yVal=yVal+1;}
if (mVal<=0){
mVal=12;
yVal=yVal-1;}
return new Date(yVal,mVal,1);
}
ASPX Part