These are issues that have been reported by others. I am raising them as a bug reports to be evaluated by Telerik staff. There are two issues reported here.
Scenario: simple app - a RadTreeView on the left, clicking on a node dynamically loads a bunch of RadControls on the right.
Issue 1: If the controls on the right are displayed for the first time (i.e. first click on the corresponding node), they are displayed just fine. However, the second time a user visits a node, the following error is shown: "Script control may not be registered after PreRender".
The stack trace is below. It is obvious from the highlighted lines what generates the problem and I don't have any control over it. Kindly suggest a workaround or issue a fix
[InvalidOperationException: Script controls may not be registered after PreRender.]
System.Web.UI.ScriptControlManager.RegisterScriptControl(TScriptControl scriptControl) +269
System.Web.UI.ScriptManager.RegisterScriptControl(TScriptControl scriptControl) +99
Telerik.Web.UI.RadWebControl.OnPreRender(EventArgs e) +39
Telerik.Web.UI.RadInputControl.OnPreRender(EventArgs e) +28
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041
"Sys.InvalidOperationException: A control is already associated with the element.
This is a showstopper and as of yet I have no explanation for it.
Both problems didn't exist before moving to the new version of the controls.
11 Answers, 1 is accepted
Please, review this post by my colleague Erjan. He has explained the problem in details and linked a project with a general solution.
I hope that helps you resolve the problem.
the Telerik team
Unfortunately I'm not sure what is causing the error in your scenario. Can you please share how do you load the user controls? I suppose the error may be thrown because of too late user control loading, but we will definitely need something to debug to be able to isolate the source of the problem.
Can you assemble a working subset of you project which replicates that? You can send it through regular support ticket. Looking forward to hearing from you.
the Telerik team
I will try to describe the code, because I have a very big solution with about 30+ projects in it and debugging on the whole thing is not an option.
Each node in my treeview is linked to an in memory object. If the object is not in memory it is loaded from the database. When the object loads, it loads some attributes which when the node is selected have to be displayed in the right-hand side of the page. Each of these attributes has a control (telerik or otherwise).
These controls are created at the time the attribute is loaded and will be displayed based on what the attribute contains. Thus whenever and attribute has to be shown, the right control is retrieved and added to the page. I can only do this operation in the PreRender stage, as I don't have all the required information before that. This works (and it worked so far with RadControls Q3 2008).
The first time one of these controls is displayed, all is ok. The second time the application crashes with the aforementioned message.
I managed to 'solve' the problem with a trick/workaround which I don't like. Every time I am displaying the control I create a new one to which I transfer all properties of the old one. I display the new control. Not sure if this will hold in the long run.
Any suggestions / fixes will be most welcome. I need to reinforce this project was working just fine on the previous release (non-prometheus).
We believe the problem is indeed caused by keeping the object in memory. You should load/recreate the controls/objects each time in order to avoid any further problems like the ScriptManager errors because of the late script registration.
I'm afraid we can't suggest any other solution. Quite the opposite, we would strongly recommend you avoid the keeping-in-memory approach.
the Telerik team
Same treeview. Clicking its nodes now displays the controls, reloaded as they are. On some postbacks however, I need to rebuild the tree. I clear the nodes, then rebuild them. However, the moment the page reloads after a rebuild, I get this JScript error which stops all js from working on the page:
"Sys.InvalidOperationException: A control is already associated with the element". The Tree is a control that is added at design time.
If I ignore the error and post the page back again I get: "Multiple controls with the same ID 'c9dc6c5c-f0e1-4cba-8187-e032563917e8' were found. FindControl requires that controls have unique IDs"
Any idea why this is? I definitely do not have duplicate IDs...
I must add that I have exactly the same 2 problems using a collection of controls created dynamically to enter portal/pages/modules settings, I have already open a previous thread on this.
I will try to extract a project presenting the dysfonction but my main projet is also rather big.
I am very interested to know any progress on theses issues may be created by choice made in ajax.net architecture. All my code was running perfectly without Ajax.net AND is running when I replace the radTextBox by normal text box...
Clearing the Contextmenu collection of the RadTree solved this.
Can you please summarize what problem remains?
Also, I believe the best way to proceed is to isolate the problem in a small project and send it to us. So, we can test it locally and find where the problem is.
All the best,
the Telerik team
uncaught exception Sys.InvalidOperationException: Sys.InvalidOperationException: Type Telerik.Web.UI.RadInputControl has already been registered. The type may be defined multiple times or the script file that defines it may have already been loaded. A possible cause is a change of settings during a partial update
But this happens only on Safari (mac/windows) and Chrome.
IE and Firefox works fine.
The control that is causing the error is a RadDatePicker.
I am having the same issue and I m loading the RadTreeview by clearing the Contextmenus and nodes. But, I come across the same issue, Script Controls may not be registered after PreRender.
Any help will be appreciated.