I'm using an older version of Telerik that doesn't have the ASP 4.0 fix and it's causing my grid control to throw an error when paging. The error is: Microsoft JScript runtime error: Object doesn't support property or method '_destroyTree'
I found a fix on these forums that works very well when used on a normal ASPX page...
<
script
type
=
"text/javascript"
>
$telerik.disposeElement = function (element) {
if (typeof (Sys.WebForms) == "undefined")
return;
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm && prm._destroyTree)
prm._destroyTree(element);
else if (Sys.Application.disposeElement)
Sys.Application.disposeElement(element, true);
};
Telerik.Web.UI.RadComboBox.prototype._removeDropDown = function () {
var slide = this.get_dropDownElement().parentNode;
slide.parentNode.removeChild(slide);
if (this._disposeChildElements)
$telerik.disposeElement(slide);
if (!$telerik.isSafari)
slide.outerHTML = null;
this._dropDownElement = null;
};
</
script
>
My problems is that I am using user controls on much of the site. If I place this in the ASCX file, I get the same error as if I didn't have it there. If I place it in the ASPX that the user control is added to, I get this error: Microsoft JScript runtime error: Unable to get value of the property 'prototype': object is null or undefined most likely because the user control with the grid isn't loaded yet.
I can place the script inside an IF statement... if (Telerik.Web.UI.RadComboBox != null) { } and that gets rid of the prototype error, but it acts like the script isn't there because I still get the original _destroyTree error.
Can someone tell me what I need to do in order to make this work inside a user control? Here's the layout of my pages...
- Master Page with update panel and placeholders.
- Inside one placeholder, I have a sidebar where I have an accordion menu.
- This placeholder is filled in with an ASPX page.
- Inside the other placeholder, I have the main content area.
- This placeholder is filled in with an ASCX user control based on what is clicked on the menu in the first placeholder.
- Separate user controls are loaded dynamically based on the menu selection.
- The user controls in this placeholder are where my grids are that need paging.
- Inside one placeholder, I have a sidebar where I have an accordion menu.
So what I need is to include the fix script in each user control that uses a grid so that I can page. If it were possible to include it on the master page so I don't have to put it on every user control, or if I could put it on the ASPX page that is in the first placeholder and have it work even when a new user control is loaded, then that would be great. But I don't mind including it in every user control if that is what's needed for this to work. I can also include a .JS file if that is what's needed. Keep in mind that these are inside an update panel, so the postback will be asynchronous in case that matters.
Any help would be greatly appreciated. It was decided that we wouldn't be updating Telerik, so I'm stuck with trying to make this work with just the script fix. This is really the only issue I'm having with Telerik and 4.0 with our site, so there isn't enough incentive to buy a newer version.
Just as a reminder, the script above works perfectly when used on a normal ASPX page that has the grid right on it rather than the grid being on a user control that is loaded later.