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

Results 1 to 2 of 2

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

  1. #1
    Join Date
    Dec 1969

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

    Hi,<BR><BR>I can&#039;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&#039;t look like it should be a very difficult problem, but I&#039;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>++++++++++++++++++++++++++++++<B R> MAIN_PAGE.aspx<BR>++++++++++++++++++++++++++++++<B R><BR><BR>&#060;%@ Page Language="VB" %&#062;<BR><BR>&#060;%@ Register TagPrefix="LHS" TagName="UserControl" src="User_Control.ascx" %&#062;<BR><BR>&#060;script language="VB" runat="server"&#062;<BR> <BR>Protected Overrides Function OnBubbleEvent(obj As Object, e As EventArgs) As Boolean<BR> Context.Response.Write("Parent Control&#039;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>&#060;/script&#062;<BR><BR>&#060;html&#062;<BR>&#060;body &#062;<BR>&#060;form runat="server"&#062;<BR><BR> &#060;LHS:UserControl runat="server" id="LHSUserControl" /&#062;<BR><BR>&#060;/form&#062;<BR>&#060;/body&#062;<BR>&#060;/html&#062;<BR><BR><BR><BR><BR>++++++++++++++++++++ ++++++++++<BR> USER_CONTROL.ascx<BR>+++++++++++++++++++++++++++++ +<BR><BR><BR><BR>&#060;%@ Control Language="VB" %&#062;<BR><BR>&#060;script language="VB" runat="server"&#062;<BR><BR>Public Sub FireEvent(obj as object, e as eventargs) <BR> RaiseBubbleEvent(obj, e)<BR>End sub<BR><BR>&#060;/script&#062;<BR><BR>&#060;asp:Button runat="server" Text="Add Person" OnClick="FireEvent" /&#062;<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Repost (HELP!) - Why TWO bubble events from ON

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts