I'm adding a control (linkbutton) dynamically using ParseControl and it's fine except when I specify an event handler.
If I use:
Dim c As Control = ParseControl("<asp:LinkButton id=""btnHide"" runat=""server"" text=""Hide"" OnClick="btnHide_Click" />")
it correctly adds the control to the page but the click event doesn't fire. If instead I find the control in the controls collection and manually wire up the event it works fine. I've tried loading in both Page_Init and Page_Load and it's the same thing either way.
Any ideas?
Edit:
In reality I'm not only parsing a single linkbutton in the code, I'm parsing a bunch of text that includes linkbuttons, checkboxes etc. I wonder if that has any bearing on it not performing as expected?