Hi -

I have a web user control that loads data from a database query into a HTML tree view that I build dynamically. The control is loaded into the main page when the user clicks a single button. The code that I use to load the control is below.

Viewer.WebControls.Legend lgnd = (Viewer.WebControls.Legend)LoadControl("WebControls/Legend.ascx");
lgnd.LayerManagerDataEvent += Viewer.WebControls.Legend.LayerManagerEventHandler( lgnd_LayerManagerDataEvent);
lgnd.LoadLegend() // this function actually calls a helper dll that supplies the HTML that foms the tree.

this.pnlControlSpace.Controls.add( lgnd );
this.pnlControlSpace.Visible = true;

Now, when I comment out the "controls.add" and the "LoadLegend" lines of code the control's page load event does not fire. However, when I go to "add" the control to the panel, the controls "page_load" event will fire twice.

I'm a little lost as to why.

Laurence -