I currently have a project in production running under ASP.NET 1.1. The
project contains a page that loads a User Control dynamically in the
Page_Load event and then adds the User Control to a placeholder controls
collection. The User Control contains several hyperlink buttons with
corresponding event handlers that perform particular functions within the
control. In some cases the control is specifically removed from the
placeholder controls collection, then re-added later in the code. After the
add, remove, add occurrs in ASP.NET 1.1, the user control's hyperlink buttons
work fine, however in ASP.NET 2.0 the user control's events are not fired at
all for any of the hyperlink (or any button on the user control).
To summarize, the event handler in the user control will not fire properly
under ASP.NET 2.0 with the following code in the Page_Load:
formsControl = Page.LoadControl(controlVirtualPath)
InnerFormControlPlaceholder.Controls.Add(formsCont rol)
InnerFormControlPlaceholder.Controls.Remove(formsC ontrol)
InnerFormControlPlaceholder.Controls.Add(formsCont rol)
Note: The code above is not the actual code in the project (no one would
actually do this), however the code above should still technically work (The
event handlers in the user control fire correctly in ASP.NET 1.1, but not in
ASP.NET 2.0).
Is this a potential bug or has something changed in the underlying
infrastructure of ASP.NET 2.0 that I should be aware of?