473,465 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Event AddHandler

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.


Nov 18 '05 #1
2 1764
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.

"Kay" <ko******@proteus.ie> wrote in message
news:#1**************@TK2MSFTNGP10.phx.gbl...
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.


Nov 18 '05 #2
Kay
Hi Kevin,

yes the autopostback property is set to true

Thanks,
Kay.

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:uQ**************@TK2MSFTNGP12.phx.gbl...
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.

"Kay" <ko******@proteus.ie> wrote in message
news:#1**************@TK2MSFTNGP10.phx.gbl...
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.



Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andy Read | last post by:
Hello all, I have the requirement to produce source code that produces an object hierarchy. Example: Root | Folder 1
3
by: Peter Vermilye | last post by:
How can I dynamically create buttons and wire them to an event handler? I have seen how I can add buttons to an event handler that are pre-created as part of the codebehind using AddHandler, but I...
5
by: Steve | last post by:
I have a datagrid in a WinForm. When the user edits an entry in the datagrid, after he leaves that field, I would like to do some cheking. What event fires when the user does that? I need to...
6
by: Charles Law | last post by:
I have a class, which implements an interface. Let's say, that the interface looks something like Public Interface IEventSinks Sub ValueChanged(sender As Object, e As ValueChangedEventArgs) Sub...
13
by: Charles Law | last post by:
Mr "yEaH rIgHt" posted the following link about a week ago in answer to my question about removing event handlers. > http://www.vbinfozine.com/t_bindevt.shtml Following on from that post, the...
7
by: Just Me | last post by:
I need to create a library sub that adds event handlers to a control. Public Shared Sub AddEvent(ByVal qq As Control, By?? ControlMouseMove As ??) So I need to pass the address of the handler or...
1
by: bill | last post by:
I'm using VS2005. I am dynamically adding a Textbox control to a Placeholder control in the page_load event of the form, but the event handler isn't firing. What am I doing wrong? Thanks...
1
by: steve | last post by:
Hi All I have a program which creates buttons on a form on loading from data in a database table and connects them to an event handler as follows... btn = New Button btn.Text =...
5
by: Carlo \(mcp\) | last post by:
Good morning I have this lines: AddHandler MyControl1.Parent.Paint, AddressOf PaintParentHandler AddHandler MyControl2.Parent.Paint, AddressOf PaintParentHandler AddHandler...
5
by: Klaudiusz Bryja | last post by:
Hi, This is for NetCF 2.0. I need to create event handling code which using reflection. I have some parameters in XML which describe how event should be handled. I have code to create...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.