Scenario:
I have a webform that has several user controls. Some of these user controls have yet another embedded user control. All this is on a multipage control with a tabstrip control. Up until now, everything has worked fine.
Now, on the second page of my multipage control (everything else has been on page one), I am adding another simple user control to collect yet more info. This is pretty standard stuff. It works just fine. However, this is duplicatable data, meaning I can have many rows of this type of data and in order to capture that, I have added a "Add Control" button to this page of the form.
Problem: When you click on the button, it adds one control, as it should. Click on it again, you get the postback, but no new control. No exception is thrown (break into debugger on all errors, handled or not is set) and I can't see why I'm not getting another control added to the form.
Code: The declarations in the code-behind class looks like this:
My click event handler:
The part that gets me is why only work ONCE? The other odd thing is that my first control is not indexed (frmAddressForm:ControlNames) where as the first one I add which is the second control on the form of this type is indexed (as per the code above: frmAddressForm3:ControlNames
I still have yet to interogate the controls collection, which I am about to do.
Anything spring to mind?
"It's easier to ask forgiveness than it is to get permission." - Rear Admiral Dr. Grace Hopper
I have a webform that has several user controls. Some of these user controls have yet another embedded user control. All this is on a multipage control with a tabstrip control. Up until now, everything has worked fine.
Now, on the second page of my multipage control (everything else has been on page one), I am adding another simple user control to collect yet more info. This is pretty standard stuff. It works just fine. However, this is duplicatable data, meaning I can have many rows of this type of data and in order to capture that, I have added a "Add Control" button to this page of the form.
Problem: When you click on the button, it adds one control, as it should. Click on it again, you get the postback, but no new control. No exception is thrown (break into debugger on all errors, handled or not is set) and I can't see why I'm not getting another control added to the form.
Code: The declarations in the code-behind class looks like this:
Code:
Public ctrl As New System.Web.UI.Control
Protected WithEvents cellAddressForm As New System.Web.UI.htmlcontrols.HtmlTableCell
My click event handler:
Code:
Private Sub btnAddAddress_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddAddress.Click
Me.ctrl = LoadControl("~/_Common/Contact/AddressForm.ascx")
ctrl.ID = "frmAddressForm" & Me.cellAddressForm.Controls.Count
Me.cellAddressForm.Controls.Add(ctrl)
End Sub
The part that gets me is why only work ONCE? The other odd thing is that my first control is not indexed (frmAddressForm:ControlNames) where as the first one I add which is the second control on the form of this type is indexed (as per the code above: frmAddressForm3:ControlNames
I still have yet to interogate the controls collection, which I am about to do.
Anything spring to mind?
"It's easier to ask forgiveness than it is to get permission." - Rear Admiral Dr. Grace Hopper