So first let me mention that this is similar to two other favorable questions posted. I have used these ( Post One, Post Two ) as references to try and help my situation but I'm not getting any closer to solving my issue.
I've added the relevant code below while also being mindful not to post a "Wall of Code".
The Goal
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.
The Issue
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.
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 LinkButton vs Button.
All feedback is welcomed. Thank you.
page.ascx
<asp:UpdatePanel ID="parentWrapper" runat="server">
<ContentTemplate>
<asp:PlaceHolder ID="itemsPlaceHolder" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
page.ascx.vb (Code-behind)
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("<script>console.log('clicked & doPostBack')</script>")
End Sub
UPDATE
itemBtn.UseSubmitBehavior = False
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 MSDN link.
This SO post helped me out Asp Button type.
Hopefully, this helps someone else.