Welcome Guest Search | Active Topics | Sign In | Register

eo:contextmenu Server Side ItemClick Event Firing Twice for Item Click Options
Sean Clark
Posted: Friday, July 22, 2011 3:53:07 AM
Rank: Advanced Member
Groups: Member

Joined: 12/24/2008
Posts: 43
Hi

Any ideas or common reasons for why a context menu item click will fire two server side events?

Cheers
Sean
eo_support
Posted: Friday, July 22, 2011 7:19:17 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

A post back always fires many events. It's what event you handle matters.

Thanks
Sean Clark
Posted: Friday, July 22, 2011 8:27:06 AM
Rank: Advanced Member
Groups: Member

Joined: 12/24/2008
Posts: 43
Sorry, I wasn't clear. The specific event that is firing twice is the ItemClick event for the menu item.

I can't think why that specific event would fire twice yet, Page_Load only fires once for that postba
eo_support
Posted: Friday, July 22, 2011 8:46:11 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

I see. The most common reason is that you hooked up your event handler multiple times. For example, the following code will cause Button1_Click to be called twice when the button is clicked:

Code: C#
//The following code hook up Click event hanlder twice. So
//Button1_Click will be called twice when the button is clicked
Button1.Click += new EventHandler(Button1_Click); 
Button1.Click += new EventHandler(Button1_Click);


There are many ways to hook up an event handler. The above code shows one way. If you use VB.NET, then you can also hook it up this way:

Code: Visual Basic.NET
Private Sub Button1_Tick(sender As Object, e As EventArgs) _
    Handles Button1.Click
   'your event handling code
   .....
End Sub


With ASP.NET, you can also hook it up directly in your ASPX, for example:

Code: HTML/ASPX
<asp:Button OnClick="Button1_Click" ....>


They all count. So for example, if you have OnClick="Button1_Click" in your ASPX and Handles Button1.Click in your .VB at the same time, then it will be called twice.

Hope this clears up.

Thanks
Sean Clark
Posted: Tuesday, July 26, 2011 5:26:16 AM
Rank: Advanced Member
Groups: Member

Joined: 12/24/2008
Posts: 43
Doh!

That was exactly the problem. The event was wired up twice!

Thanks.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.