Search code examples
asp.netvb.netascxweb-user-controls

Why the button event of a web user control does not fire?


My web user control is

<asp:DropDownList ID="cmbList" runat="server">
</asp:DropDownList>
<asp:ImageButton ID="btnDoSub" runat="server"/>

in my webpage, at the Init part, i add the control into a panel dynamically

 Private Sub Webpage_Init(sender As Object, e As System.EventArgs) Handles Me.Init
      Panel1.Controls.Add(Page.LoadControl("controls/MyControl.ascx"))
 End sub

The problem now is that the click event does not fire upon clicking at the button.

So what am i doing wrong here? How can i fix that?


Solution

  • Just give this control an ID while adding it to the panel.