Hi,
I cannot seem to dynamically create a button that responds to a button click. It's a user control that is called from a aspx page and creates dropdown and a button. I have a label to test that either says clicked or unclicked but when I run the code it is always unclicked!
Any help appreciated!
here's the code:
Public Class FavouriteManagerDropDownControl : Inherits System.Web.UI.Control
Dim favourites_dropdown As new System.Web.UI.WebControls.dropdownlist()
Dim withevents favourites_button As new System.Web.UI.htmlControls.htmlinputbutton("button"
Dim test as new label()
Private Sub favourites_button_ServerClick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles favourites_button.ServerClick
test.text="ooh I've been clicked"
End Sub
Protected Overrides Sub createchildcontrols()
favourites_dropdown.id = "favourites_dropdown"
Controls.Add(favourites_dropdown)
favourites_button.ID="favourites_button"
favourites_button.Value="Go!"
Controls.Add(favourites_button)
test.text="unlclicked"
Controls.Add(test)
'AddHandler favourites_button.ServerClick, AddressOf favourites_button_ServerClick
End Sub
end class
I cannot seem to dynamically create a button that responds to a button click. It's a user control that is called from a aspx page and creates dropdown and a button. I have a label to test that either says clicked or unclicked but when I run the code it is always unclicked!
Any help appreciated!
here's the code:
Public Class FavouriteManagerDropDownControl : Inherits System.Web.UI.Control
Dim favourites_dropdown As new System.Web.UI.WebControls.dropdownlist()
Dim withevents favourites_button As new System.Web.UI.htmlControls.htmlinputbutton("button"
Dim test as new label()
Private Sub favourites_button_ServerClick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles favourites_button.ServerClick
test.text="ooh I've been clicked"
End Sub
Protected Overrides Sub createchildcontrols()
favourites_dropdown.id = "favourites_dropdown"
Controls.Add(favourites_dropdown)
favourites_button.ID="favourites_button"
favourites_button.Value="Go!"
Controls.Add(favourites_button)
test.text="unlclicked"
Controls.Add(test)
'AddHandler favourites_button.ServerClick, AddressOf favourites_button_ServerClick
End Sub
end class