Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

$find method does not find a calendar extender behavior

$
0
0

Hi there!

I have a page with a ACT CalendarExtender which I have to enable or disable depending on some user actions, so I'm using two small javascript functions for enable or disable a ACT CalendarExtender object.

Here are they and the CE:

function enableCalendar()
{
        var ce = $find('CEBehavior');

        if (ce != null)
                ce._enabled = true;
}
function disableCalendar()
{
        var ce = $find('CEBehavior');

        if (ce != null)
                ce._enabled = false;
}<act:CalendarExtender ID="CalendarExtender" BehaviorID="CEBehavior" runat="server" TargetControlID="TextBoxDate" PopupPosition="BottomLeft" Animated="true" Format="dd/MM/yyyy" FirstDayOfWeek="Monday" PopupButtonID="ImageCalendarFP" />

There is another small javascript function which is called from the onload page event and determines whether the CE should be enable or disable.

When the page loads, that function enables or disables the CE by calling the 'enableCalendar' or 'disableCalendar' functions I wrote above and everything works fine.

But when user does a postback the '$find' sentence within the 'enableCalendar' function returns NULL because it's not able to find 'CEBehavior' and the CE is not enabled. And, what is worse, it only happens sometimes (but always during postbacks).

What could be causing this strange behavior?

Could it be that the 'onload' page event is firing before all the page source code is generated?

How could I fix it?

Thanks in advance for any help or idea.


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>