I know that in order to receive events from dynamically added controls, you need to recreate the control with each postback, and then re-attach the event handler.
This is thge first time I am trying to dynamically add a user control (ascx), which is a composite control of a couple of drop down controls, one for month and one for year.
I use the LoadControl statement to dynamically add the usercontrol. I then give the usercontrol an ID and attach an event handler, but the event handler never fires, even though I re reload the usercontrol and re-attach the event handler.
How can I process the events of the contained ddl controls within the ascx control?
I have no problem processing the events of the ascx when the usercontrol is drawn on the web form at design time.
Thanks in advance for any comments.
Here's the relevant code:
Protected WithEvents PeriodSelector As sKPIPeriodSelec tor
Dim Path As String = "../UIObjects/SKPIPeriodSelec tor.ascx"
PeriodSelector = CType(LoadContr ol(Path), sKPIPeriodSelec tor)
PeriodSelector. ID = "PeriodSelector "
AddHandler PeriodSelector. RPTChange, AddressOf PeriodSelector_ Change
Private Sub PeriodSelector_ Change()
RefreshDisplay( ) 'IT NEVER COMES IN THIS SUB!!!
End Sub
This is thge first time I am trying to dynamically add a user control (ascx), which is a composite control of a couple of drop down controls, one for month and one for year.
I use the LoadControl statement to dynamically add the usercontrol. I then give the usercontrol an ID and attach an event handler, but the event handler never fires, even though I re reload the usercontrol and re-attach the event handler.
How can I process the events of the contained ddl controls within the ascx control?
I have no problem processing the events of the ascx when the usercontrol is drawn on the web form at design time.
Thanks in advance for any comments.
Here's the relevant code:
Protected WithEvents PeriodSelector As sKPIPeriodSelec tor
Dim Path As String = "../UIObjects/SKPIPeriodSelec tor.ascx"
PeriodSelector = CType(LoadContr ol(Path), sKPIPeriodSelec tor)
PeriodSelector. ID = "PeriodSelector "
AddHandler PeriodSelector. RPTChange, AddressOf PeriodSelector_ Change
Private Sub PeriodSelector_ Change()
RefreshDisplay( ) 'IT NEVER COMES IN THIS SUB!!!
End Sub