Event fires repeatedly

D

Drex10

I have an event that occurs within a user control. The event is for a
dropdownlist within the user control which fires when the selected item
changes. This user control is created dynamicaly inside another user
control. There are other user controls created within the same
container control, however once the problem control event fires once it
fires again whith any other event fired on the page. Any ideas???
 
K

Kevin Spencer

Events are multi-cast delegates. This means that an event delegate may have
any number of event handler methods assigned to it. I am suspecting that
somehow you are re-assigning the event handler to the event accidentally.
How and when do you assign the event handler, and how often do you assign it
in the course of the application?

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

If the Truth hurts, wear it.
 
K

Kevin Spencer

Sorry, I just realized that this was an ASP.Net question (I visit a number
of groups). The delegate aspect of my answer is therefore irrelevant.
However, I do suspect that you are somehow re-assigning the event handler,
so if you can provide some information about how and when you are assigning
the event handler, that will help.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

If the Truth hurts, wear it.
 
M

Mark Rae

I have an event that occurs within a user control. The event is for a
dropdownlist within the user control which fires when the selected item
changes. This user control is created dynamicaly inside another user
control. There are other user controls created within the same
container control, however once the problem control event fires once it
fires again whith any other event fired on the page. Any ideas???

Yup! If it isn't an actual bug, then it's a feature that I don't
understand... :) Microsoft refuse to acknowledge that it even happens, but
it so clearly does...

I don't know what causes it - I can't discern any pattern to it - however,
there is thankfully a very easy (though horrible!) workaround...

<asp:DropDownList ID="MyDDL" Runat="server"
OnSelectedIndexChanged="MyDDL_SelectedIndexChanged" AutoPostBack="true">

public void MyDDL_SelectedIndexChanged(object sender, EventArgs e)
{
if (Request.Form["__EVENTTARGET"] == MyDDL.ClientID)
{
// actual code goes here
}
}
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top