This is a migrated thread and some comments may be shown as answers.

RadAjaxManager/RadScriptManager on UserControl

1 Answer 235 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
brad
Top achievements
Rank 1
brad asked on 06 Jan 2009, 03:48 PM
I have an ASPX page. on this page i have a userControl, on this User Control i have another User Control. the Purpose of the last User Control is to allow selection of a tree view, however since we have thousands of what would be nodes, we have a grid and a RadTab, the RadTab options are GridView and TreeView, the control defaults to GridView listing the thousands of possible selections, there is also a textbox which searchs the grid, whenever the grid has less then 200 items, it defaults to tree view and the items are displayed in a tree view.

now, this control is on several pages and works great. however, now since i have this control, on a User Control thats on an ASPX page, i get errors.

Microsoft JScript runtime error: 'document.getElementById(...)' is null or not an object

whenever i take out the ajax of the control, it works fine. however, when trying to use the Ajax, that error occurs whenever a search is performed on the grid (the ajax is being called)

the RadAjaxManager and RadScriptManager and RadLoadingPanel are all on the ASPX page. and im trying to reference them from the user Control.

i used the following lines of code.

ScriptManager1 = (RadScriptManager)this.Parent.Page.FindControl("ScriptManager1");
RadAjaxLoadingPanel1 = (RadAjaxLoadingPanel)this.Parent.Page.FindControl("RadAjaxLoadingPanel1");

RadAjaxManager.GetCurrent(this.Parent.Page).AjaxSettings.AddAjaxSetting(LocationSetToolBar, LocationGrid, RadAjaxLoadingPanel1);

i also tried this.parent.parent.page, just to make sure i was hitting the correct length.

any help at all would be appreciated. thx.





1 Answer, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 09 Jan 2009, 02:35 PM
Hello brad,

Thank you for the detailed explanation.

It seems that some DOM element you are referencing using the document.getElementById(id) method is not initialized at the time you are attempting to do that. It is indeed odd that the same scenario works with plain postbacks instead of ajax requests. Can you please debug your client code to see why this element is not accessible by that time?

Furthermore, is it possible for you to share with us the relevant code logic inside user controls and the main page (including the document.getElementById method invocation) by pasting the code snippets in this forum thread? You can use the 'Format Code Block' option from the ticket editor in order to format and align the code excerpts and keep their readability as in Visual Studio. We will do our best to assist you in addressing the javascript error asap.

Kind regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Ajax
Asked by
brad
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or