Hi All,

My Question is about Loading user controls via DirectMethod.

I have the following scenario:
According to some database information, I have to Load a User Control based on the count of records I am getting.
So, in order to achieve this, here is the complete process flow:

The User Control markup looks like the following:
<ext:FormPanel runat="server" ID="pnl1" >
    .... some controls 
</ext:FormPanel>
The Page Markup looks like this:
<body>
..
 <ext:Panel runat="server" id="pnlContainer"> </ext:Panel>
..
</body>

1- I Exposed the FormPanel inside the user control as a public read only property:
public readonly FormPanel RootPanel {
     get { return this.pnl1; }
}
Inside my Page
2- I declared a private member as a reference for my control.

2- During Page Initialization I used
    myUserControl = (myUserControl)Page.LoadControl(..ascx);
    myUserControl.Id = "someid";
3-Inside the DirectMethod i am calling the
    myUserControl.RootPanel.Render(this.pnlContainer);
Up to this stage, every thing is working great.

But when I repeat rendering process several times as follow:
    myUserControl.RootPanel.Render(this.pnlContainer);
    Instance2OfMyUserControl.RootPanel.Render(this.pnlContainer);
I am getting this error from the server
A Control with an ID of pnl1 has already been initialized. Please ensure that all Controls have a unique id.

I've tried setting IDMode="Legacy" if this what it means on the resource manager. but I am still stuck.

Thanks for your help.