[CLOSED] [2.2] DirectEvents "An error has occurred because a control..."

  1. #1

    [CLOSED] [2.2] DirectEvents "An error has occurred because a control..."

    "An error has occurred because a control with id 'ctl00$cp$ctl07' could not be located or a different control is assigned to the same ID after postback."


    I've been seeing errors like this only recently but only in directevent postback on a page where a lot of dynamic controls are created. The problem is, the shear number of controls and complexity is making it virtually impossible for me to produce a reproducible test sample with the same situation.

    I need clues on what to look for. I verified that the issue is not that the loading of missing usercontrols.

    The first time I had this problem, I had rewrite menu control loader that moved some controls from one loaded user control and move it to another control elsewhere. That problem went away after I updated the loader to move the control from a user control before adding the user control to the items of a usercontrolloader.

    This time, I'm trying to load a UserControl with a ext:Window in its contents from a UserControlLoader that is being added into a Panels Bin.Add().

    I cannot trap on the Page_Load of the UserControl which is why I'm getting the error above. It's not executing the pageload event even though the user control is loaded.

    Thoughts?
    Last edited by Daniil; Aug 06, 2013 at 8:26 AM. Reason: [CLOSED]
  2. #2
    Hi @michaeld,

    It worked for me as well. Do you mind we close the thread or you are working on another test case?
  3. #3
    I've revised and added...
    Last edited by michaeld; Jul 30, 2013 at 6:05 AM.
  4. #4
    I have 2 versions of essentially the same code below. One traps at the breakpoint I set in Page_Load of the User control referenced by the string taskctl.

    This one does not trap at Page_Load on postback or initial load...
                    var ctl = new UserControlLoader( new UserControlLoader.Config() { Path = taskctl } );
                    ctl.UserControlID = "TaskUC" + i.ToString();
                    ProfP.Bin.Add( ctl );
    This version traps at Page_Load on both postback and initial load...
                    var uc = Page.LoadControl( taskctl ) as UserControl;
                    var ctl = new UserControlLoader();
                    ctl.Items.Add( uc );
                    ctl.UserControlID = "TaskUC" + i.ToString();
                    ProfP.Bin.Add( ctl );
    Both versions upon loading the Bin.Add user control will produce the error msg I indicated at the top of this thread.

    If I remark out this section and postback, the direct event runs normally without any errors.
    Last edited by michaeld; Jul 30, 2013 at 6:32 AM.
  5. #5

    Viola! I think I found it.

    I think I may have some clues to what is causing the original failure message behavior. The issue is that the postback requires that every control that was rendered before be in the exact same position as it was when it was rendered the first time.

    For performance reasons I was skipping some of the reorganization steps on the postback. When I removed this step, the problem went away. This was throwing off UserControlLoader ids or postback viewstate binding on postback or something.

    I cannot explain why the code differences above had any impact on behavior but I suspect there's a clue in there. I'm guessing how it renders or manages ids. Typically, I don't believe this would be an issue if I used a classic Page.LoadControl and skipped the reorder because all the ids were present, just in different locations. I can't confirm but I'm pretty sure I didn't have these problems in the 1.0 version.

    Anyway, you can close this item unless you want to discuss or evaluate further why this might happen in UserControlLoader.
  6. #6
    Quote Originally Posted by michaeld View Post
    Typically, I don't believe this would be an issue if I used a classic Page.LoadControl and skipped the reorder because all the ids were present, just in different locations.
    I guess the same should be reproducible with a pure LoadControl without a UserControlLoader. We don't do anything special in a UserControlLoader. However, anything is possible. We would be happy to investigate a test case if you can provide.

Similar Threads

  1. [CLOSED] How to add a HTML table to a Panel control dynamically
    By Fahd in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 21, 2012, 7:03 PM
  2. Replies: 9
    Last Post: Dec 07, 2012, 11:42 AM
  3. [CLOSED] panel icon missing when dynamically load a user control
    By CarpFisher in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Jul 30, 2012, 7:47 AM
  4. [CLOSED] [RAZOR] Dynamically load contents into Panel
    By gets_gui in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 04, 2012, 10:45 PM
  5. Replies: 0
    Last Post: May 03, 2010, 4:33 AM

Posting Permissions