N
Nathan Sokalski
I am trying to dynamically add controls to my page, but am having trouble
with controls such as buttons. I have been able to add simple controls such
as Label controls, because they can be placed anywhere. I have managed to
add Labels using the following code:
Dim extralabel As Label = New Label
extralabel.Text = "Generated Label"
Me.Controls.Add(extralabel)
This places the label at the very end of the generated code inside SPAN
tags. However, when I try something similar with a Button control using the
following code:
Dim extrabutton As Button = New Button
extrabutton.Text = "Generated Button"
Me.Controls.Add(extrabutton)
I recieve an error telling me that a Button control must be between FORM
tags (which makes sense, since a Button control generates an INPUT tag). I
am having trouble figuring out how to add the Button control so that it is
between the form tags. Does anyone know how to do this? A simple example
would be nice. Any help would be appreciated. Thanks.
with controls such as buttons. I have been able to add simple controls such
as Label controls, because they can be placed anywhere. I have managed to
add Labels using the following code:
Dim extralabel As Label = New Label
extralabel.Text = "Generated Label"
Me.Controls.Add(extralabel)
This places the label at the very end of the generated code inside SPAN
tags. However, when I try something similar with a Button control using the
following code:
Dim extrabutton As Button = New Button
extrabutton.Text = "Generated Button"
Me.Controls.Add(extrabutton)
I recieve an error telling me that a Button control must be between FORM
tags (which makes sense, since a Button control generates an INPUT tag). I
am having trouble figuring out how to add the Button control so that it is
between the form tags. Does anyone know how to do this? A simple example
would be nice. Any help would be appreciated. Thanks.