Repost (HELP!) - Why TWO bubble events from ONE cl

Heather

New Member
Hi,<BR><BR>I can't work out why clicking ONCE on the button in User_Control.ascx causes TWO bubble events to fire in the parent page Main_Page.aspx (all code below).<BR><BR>Both events are reported in the main page as having the same source object (unsurprisingly, the button), but have different event arguments (the first "System.EventArgs", the second "System.Web.UI.WebControls.CommandEventArgs").<BR><BR>This "double" event from one click is causing all kinds of things to go wrong in the rest of the page, I really need to fix this! Can anyone tell me what on earth is going on? This doesn't look like it should be a very difficult problem, but I've asked around everywhere I know, and no one seems to be able to explain it!<BR><BR>Any help much appreciated,<BR><BR>Thanks!<BR><BR>JON<BR><BR><BR><BR><BR><BR><BR>++++++++++++++++++++++++++++++<BR> MAIN_PAGE.aspx<BR>++++++++++++++++++++++++++++++<BR><BR><BR><%@ Page Language="VB" %><BR><BR><%@ Register TagPrefix="LHS" TagName="UserControl" src=http://aspmessageboard.com/archive/index.php/"User_Control.ascx" %><BR><BR><script language="VB" runat="server"><BR> <BR>Protected Overrides Function OnBubbleEvent(obj As Object, e As EventArgs) As Boolean<BR> Context.Response.Write("Parent Control's BubbleEvent is called.")<BR> Context.Response.Write("Source of event is:" & obj.ToString())<BR> Context.Response.Write("EventArgs are:" & e.ToString())<BR> Return True<BR>End Function<BR><BR> <BR></script><BR><BR><html><BR><body><BR><form runat="server"><BR><BR> <LHS:UserControl runat="server" id="LHSUserControl" /><BR><BR></form><BR></body><BR></html><BR><BR><BR><BR><BR>++++++++++++++++++++++++++++++<BR> USER_CONTROL.ascx<BR>++++++++++++++++++++++++++++++<BR><BR><BR><BR><%@ Control Language="VB" %><BR><BR><script language="VB" runat="server"><BR><BR>Public Sub FireEvent(obj as object, e as eventargs) <BR> RaiseBubbleEvent(obj, e)<BR>End sub<BR><BR></script><BR><BR><asp:Button runat="server" Text="Add Person" OnClick="FireEvent" /><BR>It looks like your control button is raising the event manually by calling the FireEvent method. Then after that method is called, the normal "click" event bubbles like normal and once again - raises the event for a second time. You should not have to manually raise the event for the bubble to occur. If you need to raise the event manually for any reason then you should also "cancelBubble" after you raise the event - so the "current" click event does not bubble and cause the event to be raised again.
 
Back
Top