开发者

Problem with events and ParseControl

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=""btnHi开发者_如何学编程de"" 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?


Have you try this:

Dim c As LinkButton = ParseControl("<asp:LinkButton id=""btnHide"" runat=""server"" text=""Hide""  />")
AddHandler c.Click, AddressOf btnHide_Click
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜