A control cannot modify its parents' control collections.

A

Alexandru Nedelcu

Hi!!!

I'm trying to add a UserControl created using the
Page.LoadCotnrol("test.ascx") method to a Page's Control collection and
the exception I get is ( the complete stack trace):

[HttpException (0x80004005): A control cannot modify its parents'
control collections.]
System.Web.UI.ControlCollection.Add(Control child)
Akela.WebFramework.Design.TreeView.TreeNode.LoadUserControl() in
d:\projects\akelahr\localsourcesafe\akelahrenterprise\akela.webframework\design\treeview\treenode.cs:451
Akela.WebFramework.Design.TreeView.TreeNode.get_UserControl() in
d:\projects\akelahr\localsourcesafe\akelahrenterprise\akela.webframework\design\treeview\treenode.cs:417
Akela.WebFramework.Design.TreeView.TreeNode.TrackViewState() in
d:\projects\akelahr\localsourcesafe\akelahrenterprise\akela.webframework\design\treeview\treenode.cs:1319

Akela.WebFramework.Design.TreeView.BaseChildNode.System.Web.UI.IStateManager.TrackViewState()
in
d:\projects\akelahr\localsourcesafe\akelahrenterprise\akela.webframework\design\treeview\basechildnode.cs:255

Akela.WebFramework.Design.TreeView.BaseChildNodeCollection.System.Web.UI.IStateManager.TrackViewState()
in
D:\Projects\AkelaHR\LocalSourceSafe\AkelaHREnterprise\Akela.WebFramework\Design\TreeView\BaseChildNodeCollection.cs:472
Akela.WebFramework.Design.TreeView.TreeNode.TrackViewState() in
d:\projects\akelahr\localsourcesafe\akelahrenterprise\akela.webframework\design\treeview\treenode.cs:1318

Akela.WebFramework.Design.TreeView.BaseChildNode.System.Web.UI.IStateManager.TrackViewState()
in
d:\projects\akelahr\localsourcesafe\akelahrenterprise\akela.webframework\design\treeview\basechildnode.cs:255

Akela.WebFramework.Design.TreeView.BaseChildNodeCollection.System.Web.UI.IStateManager.TrackViewState()
in
D:\Projects\AkelaHR\LocalSourceSafe\AkelaHREnterprise\Akela.WebFramework\Design\TreeView\BaseChildNodeCollection.cs:472

Akela.WebFramework.Design.TreeView.BaseChildNodeCollection.SetViewStateDirty()
in
D:\Projects\AkelaHR\LocalSourceSafe\AkelaHREnterprise\Akela.WebFramework\Design\TreeView\BaseChildNodeCollection.cs:206

Akela.WebFramework.Design.TreeView.TreeView.CopyXmlNodesIntoTree(TreeNodeCollection
col, Object dest) in
d:\projects\akelahr\localsourcesafe\akelahrenterprise\akela.webframework\design\treeview\treeview.cs:1462
Akela.WebFramework.Design.TreeView.TreeView.ReadTreeNodeXmlSrc() in
d:\projects\akelahr\localsourcesafe\akelahrenterprise\akela.webframework\design\treeview\treeview.cs:1437
Akela.WebFramework.Design.TreeView.TreeView.OnInit(EventArgs e) in
d:\projects\akelahr\localsourcesafe\akelahrenterprise\akela.webframework\design\treeview\treeview.cs:851
System.Web.UI.Control.InitRecursive(Control namingContainer)
System.Web.UI.Control.InitRecursive(Control namingContainer)
System.Web.UI.Control.InitRecursive(Control namingContainer)
System.Web.UI.Page.ProcessRequestMain()


Can anyone give a hint?

Thanks in advance,
Alex
 
J

John Saunders

Alexandru Nedelcu said:
Hi!!!

I'm trying to add a UserControl created using the
Page.LoadCotnrol("test.ascx") method to a Page's Control collection and
the exception I get is ( the complete stack trace):

[HttpException (0x80004005): A control cannot modify its parents'
control collections.] ....

Can anyone give a hint?

Yes. "Don't _do_ that!"

:)

Add the user control to the Controls collection of the control whose event
you're handling.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top