Quantcast
Channel: AjaxControlToolkit Work Item Rss Feed
Viewing all articles
Browse latest Browse all 4356

Commented Issue: "'_events' is null or not an object" javascript exception when postback occurs with ValidatorCallout visible on page [26478]

$
0
0
I had this issue and sent a request to a 3rd party control company which verified that the problem is with the ValidatorCallout javascript. Here is the response:

This issue, as it turned out, is not related to RadInput controls or any of the Telerik AJAX controls. The exception you are getting originates from a failing method in the ValidationCalloutExtender, and more specifically, from the PopupBehavior object that is used internally by the callout.
What happens is that PopupBehavior attaches event handlers to all the parent containers of the component's container element and tries to remove the event handlers when the object is disposed. The control does not, however, check if the event handlers have already been disposed. As a result, if the handler that is tried to be removed is already removed (as happens when the element is a container of another script control), you are getting this exception.

This issue can be observed using a very simple setup:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel runat="server" ID="pnlTest">
<ajax:ValidatorCalloutExtender ID="vceFName" runat="server" Enabled="True" TargetControlID="rfvFName" />
<asp:TextBox ID="txtFName" runat="server" />
<asp:RequiredFieldValidator ID="rfvFName" runat="server" ControlToValidate="txtFName"
Display="None" ErrorMessage="First Name is Required" SetFocusOnError="True" />
<br />
<asp:Button runat="server" ID="Button2" Text="Validate" />
<asp:Button runat="server" ID="Button3" Text="Cancel" CausesValidation="false" OnClientClick="$get('form1')._events = null;" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>

In the above markup, clicking the Cancel button will simulate the exception you are getting, as the _events object has been manually removed by the time the dispose method of the PopupBehavior is called.

To fix this issue, you will need to modify the dispose method of the PopupBehavior object from the AjaxControlToolkit to the following:
AjaxControlToolkit.PopupBehavior.prototype.dispose = function()
{
/// <summary>
/// Dispose the PopupBehavior
/// </summary>
var element = this.get_element();
if (element)
{
if (this._visible)
{
this.hide();
}
if (this._originalParent)
{
element.parentNode.removeChild(element);
this._originalParent.appendChild(element);
this._originalParent = null;
}
// Remove expando properties
element._hideWindowedElementsIFrame = null;
}
this._parentElement = null;
// Remove the animation ended events and wipe the animations
// (we don't need to dispose them because that will happen
// automatically in our base dispose)
if (this._onShow && this._onShow.get_animation() && this._onShowEndedHandler)
{
this._onShow.get_animation().remove_ended(this._onShowEndedHandler);
}
this._onShowEndedHandler = null;
this._onShow = null;
if (this._onHide && this._onHide.get_animation() && this._onHideEndedHandler)
{
this._onHide.get_animation().remove_ended(this._onHideEndedHandler);
}
this._onHideEndedHandler = null;
this._onHide = null;
if (this._onParentRepositionHandler != null)
{
$removeHandler(window, 'resize', this._onParentRepositionHandler);
}
if (this._elementsWithAttachedRepositionHandlers != null)
{
for (var i = 0; i < this._elementsWithAttachedRepositionHandlers.length; i++)
{
if (this._elementsWithAttachedRepositionHandlers[i]._event)
{
$removeHandler(this._elementsWithAttachedRepositionHandlers[i], 'resize', this._onParentRepositionHandler);
$removeHandler(this._elementsWithAttachedRepositionHandlers[i], 'scroll', this._onParentRepositionHandler);
}
}
this._elementsWithAttachedRepositionHandlers = null;
}
this._onParentRepositionHandler = null;
AjaxControlToolkit.PopupBehavior.callBaseMethod(this, 'dispose');
}

Above is the overriden dispose method of the PopupBehavior, where a check has been included (the bold if statement) before removing the event handlers. You need to either modify the debug and release versions of PopupBehavior.js from the control toolkit project and rebuild the toolkit from source, or use this script in every page you use callout extenders and any kind of popups from the AJAX toolkit.
Comments: Still not fixed in December 2013 (3.5.7.1213) Release; I had to patch it myself. I'm this >< close to abandoning ACT in favor of pure jquery-ui or jquery-ui wrapped in Webforms Controls like Juice-UI.

Viewing all articles
Browse latest Browse all 4356

Trending Articles



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