Change Control's Parent Object in CodeBehind

  1. #1

    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
  2. #2
    Hi Alex,

    Please provide a test case to investigate.
  3. #3
    Hello Daniil,

    When preparing a test case (removing irrelevant code from my application) I've found the problem. No error was appearing but having multiple toolbar separators without an unique ID was the cause preventing display of page's toolbar. Now it's solved.

    Thank you. Regards...

Similar Threads

  1. Replies: 8
    Last Post: Nov 28, 2013, 6:39 AM
  2. [CLOSED] Change parent (iFrame parent) title
    By bayoglu in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 18, 2013, 1:54 PM
  3. Replies: 2
    Last Post: Jan 09, 2013, 12:52 AM
  4. Replies: 6
    Last Post: Dec 07, 2011, 12:55 PM
  5. change status of a control from codebehind
    By supermanwah in forum 1.x Help
    Replies: 4
    Last Post: May 13, 2009, 11:18 AM

Tags for this Thread

Posting Permissions