3

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

4
  • Does your Page have a ScriptManager Control on it? (msdn.microsoft.com/en-us/library/bb398863.aspx) Commented Aug 12, 2015 at 12:35
  • Nope, only the Master Page has. Commented Aug 12, 2015 at 12:38
  • is the scriptmanager added before all the update panels ,and before the contentplaceholder on the master page? Commented Aug 26, 2015 at 14:42
  • Yes, I fixed it allready by changing the updatePanel id in the usercontrols Commented Aug 26, 2015 at 14:53

2 Answers 2

1
+100

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
}
Sign up to request clarification or add additional context in comments.

1 Comment

This seems to be the only way to do it
0

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

1 Comment

In the comments on my question I tell someone there's allready a ScriptManager on the master page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.