3
votes

Allright so I have a slight issue when I want to load some basic usercontrols which contain an UpdatePanel inside to another page which is an usercontrol.

The set up:

Whenever an user clicks on a button a pop-up shows up containing some basic info on a certain person and a tab which contains the companies he worked for. The amount of companies he/she works for can range from 1 to 4~, so I do a query then for each company I get I add a view to a multiview, this view contains multiple simple user controls (Textfields inside an updatepanel). Now whenever I go to the page I get this error:

Cannot unregister UpdatePanel with ID 'UpdatePanel2' since it was not registered with the ScriptManager. This might occur if the UpdatePanel was removed from the control tree and later added again, which is not supported. Parameter name: updatePanel

Now I know this is a common error caused by generating UpdatePanels dynamically which aren't registered with the ScriptMaster. I can't add a PreInit event handler to the page which adds the UserControls with the UpdatePanels since it's an UserControl itself.

My question is:

How can I get rid of this nasty error in a not so nasty way e.g. not a hardcoded sub routine which adds the UpdatePanel to the scriptmaster

2
Does your Page have a ScriptManager Control on it? (msdn.microsoft.com/en-us/library/bb398863.aspx) - NoAlias
Nope, only the Master Page has. - DieVeenman
is the scriptmanager added before all the update panels ,and before the contentplaceholder on the master page? - Thorarins
Yes, I fixed it allready by changing the updatePanel id in the usercontrols - DieVeenman

2 Answers

1
votes

You could define the functionality you want to add inside your user controls. I have done the same in the past, adding the following, inside of my user control.

override protected void OnInit(EventArgs e) {
 // your code here
}
0
votes

Add a ScriptManager on your MasterPage before the UpdatePanel. And your updatePanel is a bit confusing so might change it as well. :)