Event AddHandler

  • Thread starter Thread starter Kay
  • Start date Start date
K

Kay

Hello,

I have a dropdown list control on my form, sometimes I want the
SelectedIndexChanged event to be handled and other times I want it to be
ignored, so I programmatically add a handler for the SelectedIndexChanged
event. The ID of my dropdown list is "ddlAlerts", the method I want to call
when the event fires is "ddlAlert_SelectedIndexChanged".

To add the handler I have the following line of code

AddHandler ddlAlert.SelectedIndexChanged, AddressOf
ddlAlert_SelectedIndexChanged

The method to handle the event is coded as follows:
Protected Sub ddlAlert_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs)

code in here

End Sub



My Problem is that the method to handle the event never gets called, even
though the handler is added before the page displays, and I select an
option from the dropdown list. Am I not doing something correctly?



Thanks in advance for any help,

Kay O'Keeffe.
 
Did you set the AutoPostBack property of the DropDownList to True? It is
false by default.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Back
Top