Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2235
webMonthCalendar Initialize events..
posted

I am trying to run a client side script on the initialize event of the control.

I am converting from the old webcalendar to the new one.

I have some code on the server side like below..

wbcCal1.ClientEvents.Initialize = "initCalendars"
wbcCal2.ClientEvents.Initialize = "initCalendars"
wbcCal3.ClientEvents.Initialize = "initCalendars"

etc..

The javascript is:

function initCalendars(sender,e) {
            var cal0 = $find("wbcCal1");
            if (owner == cal0)
                sixCalendars[0] = cal0;
            var cal1 = $find("wbcCal2"); // document.getElementById("wbcCal2");
            if (owner == cal1)
                sixCalendars[1] = cal1;
            var cal2 = document.getElementById("wbcCal3");
            if (owner == cal2)
                sixCalendars[2] = cal2;
            var cal3 = document.getElementById("wbcCal4");
            if (owner == cal3)
                sixCalendars[3] = cal3;
          
            if (cal0 != null && cal1 != null && cal2 != null ) {
 
                var year = cal0._days[15].year;
                var month = cal0._days[15].month + 1;
                if (month > 12) {
                    year++;
                    month = 1;
                }
 
                if (cal1._days[15].year != year || cal1._days[15].month != month)
                    cal1.setVisibleMonth(new Date(year, month - 1, 1));
 
                if (++month > 12) {
                    year++;
                    month = 1;
                }
 
                if (cal2.control._days[15].year != year || cal2.control._days[15].month != month)
                    cal2.setVisibleMonth(new Date(year, month - 1, 1));
 
                if (++month > 12) {
                    year++;
                    month = 1;
                }
 
                if (cal3.control._days[15].year != year || cal3.control._days[15].month != month)
                    cal3.setVisibleMonth(new Date(year, month - 1, 1));
 
                if (++month > 12) {
                    year++;
                    month = 1;
                }
 
              
 
      
            }
        }

                
The js above has been trimmed, but you can get the idea.
On the page load, the initialize event fires and I can get the control for the first calendar   "wbcCal1"
however, parsing through the list I can't get the second or third controls.

So I am not even sure I am getting/using the correct terminology to get the controls correctly.
and second, will this even work? I tried putting this code in the page_initComplete to make sure the controls were rendered but still no joy.

Some guidance on which is the proper event to call to get the objects would be helpful.
         
Parents
No Data
Reply
  • 49378
    posted

    Hello Daryl007,

    As it cannot be guaranteed when the controls are initialized, I would suggest subscribing the handler only to the initialize event of the last WebMonthCalendar on the page (which is likely wbcCal4 in this case). While it cannot be guaranteed, it is likely that the Initialize of the last calendar will be fired after the initialize events of all other calendar controls, giving access to all clientside objects.

    Hope this helps. Please do not hesitate to contact me with any questions.

Children