title: Dynamic button controls not binding to event handler in VB.NET
body: <p>So first let me mention that this is similar to two other favorable questions posted. I have used these ( <a href="https://stackoverflow.com/questions/13751376/dynamic-button-not-working-with-addhandler-in-vb-net">Post One</a>, <a href="https://stackoverflow.com/questions/13638582/addhandler-event-on-dynamic-button-incorrect-instance-properties-in-vb-net">Post Two</a> ) as references to try and help my situation but I'm not getting any closer to solving my issue. </p>
  
  <p>I've added the relevant code below while also being mindful not to post a "Wall of Code". </p>
  
  <p><strong>The Goal</strong></p>
  
  <p>So what I'm trying to do is add a click event to the programmatically created Buttons. Each button will initiate a postBack and save data to a Database without re-rendering the entire page.</p>
  
  <p><strong>The Issue</strong></p>
  
  <p>My Code below DOES compile but the event is not bound to the controls when the page renders and nothing indicates that the "click" event is bound to the buttons. </p>
  
  <p>I'm wondering if I'm doing something wrong or if I'm forced to use some hack or as one of the posts suggested using LinkButtons. However, LinkButtons are an inappropriate use for this scenario, in my opinion. I'm also referencing <a href="http://www.dotnetfunda.com/articles/show/99/difference-between-asplinkbutton-aspimagebutton-aspbutton-and-asphyper" rel="nofollow noreferrer">LinkButton vs Button</a>.</p>
  
  <p>All feedback is welcomed. Thank you.</p>
  
  <p><strong>page.ascx</strong></p>
  
  <pre><code>&lt;asp:UpdatePanel ID="parentWrapper" runat="server"&gt;
    &lt;ContentTemplate&gt;
      &lt;asp:PlaceHolder ID="itemsPlaceHolder" runat="server" /&gt;
    &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p><strong>page.ascx.vb (Code-behind)</strong> </p>
  
  <pre><code>Protected Sub Items_Load()
    'For Brevity purposes, only the itemBtn
    'is added to the parent controller. Other controls are omitted on purpose.
    'There are 200 other items that will be rendered as well.
  
    Dim itemContainer = New WebControl(HtmlTextWriterTag.Div),
        itemBtn = New Button()
  
    itemBtn.Text = "select"
    itemBtn.UseSubmitBehavior = False
    AddHandler itemBtn.Click, AddressOf ItemSelectBtn_Click
  
    itemContainer.Controls.Add(itemBtn)
  
    WorkshopsPlaceHolder.Controls.Add(itemContainer)
  
  End Sub
  
  Private Sub ItemSelectBtn_Click(ByVal sender As Object, ByVal e As EventArgs)
          Response.Write("&lt;script&gt;console.log('clicked &amp; doPostBack')&lt;/script&gt;")
  End Sub
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <pre><code>itemBtn.UseSubmitBehavior = False
  </code></pre>
  
  <p>So I was doing alot of research and this is, so far, the best option to help me achieve my goal. I'm not sure what the original page or website helped me but it led me to this <a href="https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.button.usesubmitbehavior?view=netframework-4.7.2" rel="nofollow noreferrer">MSDN link</a>. </p>
  
  <p>This SO post helped me out <a href="https://stackoverflow.com/questions/4608921/asp-button-with-different-button-type">Asp Button type</a>.</p>
  
  <p>Hopefully, this helps someone else.</p>