Event AddHandler

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.
 
K

Kevin Spencer

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top