Problem with events and ParseControl

Posted by Richard Edwards on Stack Overflow See other posts from Stack Overflow or by Richard Edwards
Published on 2010-04-16T14:02:55Z Indexed on 2010/04/16 21:03 UTC
Read the original article Hit count: 239

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?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about parsecontrol