Need some help with ASP.NET and VB.NET (sorry Mark), there's also a liberal sprinkling of AJAX.
The main aspx page is basically as follow:
html code:
<body>
<form>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
...some other stuff here
<asp:Panel ID="PreviewPanel" runat="server" BackColor="#F7F6F3">
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
In the asp:Panel called PreviewPanel I want to inject some dynamically created controls. Namely some test text boxes and labels controls which are contained in a Div, to prove it works before I create the code necessary to iterate a database and create potentially dozens of controls. All of which will have the same three buttons attached and call the same event handler.
The basic structure is something like this:
asp.net code:
<div>
...some controls
<div>
<button1> <button2><button3>
</div>
</div>
All of the divs have the runat="server" attribute applied.
Once this structure is created, I inject this code into the Panel called PreviewPanel. This bit works OK.
The problem I have is how do I wire the button controls up so they can postback to the server to perform some action.
I create the buttons with the following code:
vb.net code:
Dim Button1 As New Button
AddHandler Button1.Click, AddressOf HandleButton1Click
Button1.Text = "Button"
Button1.ID = "Button1"
---------
Private Sub HandleButton1Click(ByVal sender As Object, ByVal e As System.EventArgs)
' do something here
End Sub
When it is executed locally it basically doesn't work. The event handler doesn't get executed and the preview panel disappears from screen.
I know very little about web-development so this is probably all bollocks, but any advice appreciated.
I'm stuck, anyone help me?
Cheers