CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2003
    Location
    Riga, Latvia
    Posts
    33

    Bubble event doesn't work everytime

    Hello, guys.

    Have a problem.

    Say, I have a handler from grid, that should bubble an event to the top conrols:

    protected void grdCounterOffers_RemoveItemCommand(object sender, GridCommandEventArgs e)
    {
    base.RaiseBubbleEvent(sender, (EventArgs)e);
    }

    The GridCommandEventArgs is inherited from CommanEventArgs, and I need this class to have the ID of the item to be removed from grid.

    Whenever I pass the e, which is not null, the handler on the top control is not called. If I pass null, it's called.

    Can you please explain me why? And how can I correctly pass the desired parameter in the args to the top controls?

  2. #2
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Bubble event doesn't work everytime

    Code:
    protected void grdCounterOffers_RemoveItemCommand(object sender, GridCommandEventArgs e)
    { 
    base.RaiseBubbleEvent(sender, (EventArgs)e);
    }
    Whats the EventArguments Class of the BubbleEvent?
    Is it really EventArgs or is it another Type ?
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  3. #3
    Join Date
    Dec 2003
    Location
    Riga, Latvia
    Posts
    33

    Re: Bubble event doesn't work everytime

    Quote Originally Posted by JonnyPoet View Post
    Code:
    protected void grdCounterOffers_RemoveItemCommand(object sender, GridCommandEventArgs e)
    { 
    base.RaiseBubbleEvent(sender, (EventArgs)e);
    }
    Whats the EventArguments Class of the BubbleEvent?
    Is it really EventArgs or is it another Type ?
    Here're the inheritance:

    public class GridCommandEventArgs : CommandEventArgs
    public class CommandEventArgs : EventArgs

    When I used reflector, I noticed, that there're no dependance from passed argument type.

    One more thing: the event is fired from the control, which is located in a repeater on another control, and should be handled in that top control.
    Last edited by Takhir; October 15th, 2009 at 12:34 PM.

  4. #4
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Bubble event doesn't work everytime

    Quote Originally Posted by Takhir View Post
    Here're the inheritance:

    public class GridCommandEventArgs : CommandEventArgs
    public class CommandEventArgs : EventArgs

    When I used reflector, I noticed, that there're no dependance from passed argument type....
    Yes but if RaiseBubbleEvent only accepts the base Class EventArgs then IMHO it doesn't use any of your arguments which are maybe part of GridCommandEventArgs. Is there any recasting done ?
    Have you already looked if grdCounterOffers_RemoveItemCommand is ever called so it is able to fire the event in the baseclass ?
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  5. #5
    Join Date
    Dec 2003
    Location
    Riga, Latvia
    Posts
    33

    Re: Bubble event doesn't work everytime

    Quote Originally Posted by JonnyPoet View Post
    Yes but if RaiseBubbleEvent only accepts the base Class EventArgs then IMHO it doesn't use any of your arguments which are maybe part of GridCommandEventArgs. Is there any recasting done ?
    Have you already looked if grdCounterOffers_RemoveItemCommand is ever called so it is able to fire the event in the baseclass ?
    Of course. The grdCounterOffers_RemoveItemCommand is being called successfully, and the event is fired. I also noticed that if the args=null, then repeater doesn't handle it and passes to the top, where I catch it successfully. But if the args is not null or whatever type is, the repeater catches it and doesn't pass it forward.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured