DYnamically Loaded Web User Control Posts Twice
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.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL