Nov 02, 2014, 1:29 AM
Change Control's Parent Object in CodeBehind
Hello,
I have an empty toolbar (tb1) in a master page and another toolbar (tb2) with items in an specific page that inherits from the master page.
I want to place tb2 in the position of tb1. Because Parent property is read-only, I've tried using tb1.Parent.Controls.Add(tb2) and then removing tb2 from it's parent and hide tb1, but no success: tb2 doesn't appear where tb1 was. Any hint?
In a second attempt, I've tried to copy tb2 items into tb1 items, then clear tb2 items collection. But then when using FindControl an error raises because duplicate IDs. Again, any hint?
Thank you
Regards
Alex
I have an empty toolbar (tb1) in a master page and another toolbar (tb2) with items in an specific page that inherits from the master page.
I want to place tb2 in the position of tb1. Because Parent property is read-only, I've tried using tb1.Parent.Controls.Add(tb2) and then removing tb2 from it's parent and hide tb1, but no success: tb2 doesn't appear where tb1 was. Any hint?
In a second attempt, I've tried to copy tb2 items into tb1 items, then clear tb2 items collection. But then when using FindControl an error raises because duplicate IDs. Again, any hint?
Thank you
Regards
Alex