Control in template does not bubble events

Discussion in 'ASP .Net Web Controls' started by Iain, Jun 11, 2006.

  1. Iain

    Iain Guest

    THis is more than likely something silly I'm doing.

    (ASP.NET 2.0 W2003)

    I've written a templated databound custom control which works. Except.

    If I put a control (such as a LinkButton) in one of the templates, then no
    event is bubble up when it is clicked.

    the control is added to teh control tree (apparently correctly).

    If I add the 'same' control to the Controls collection in code then the
    event bubbling works correctly.

    However if instead I add the control to the Controls collection of the
    Container for the template (the one which I call InstatiateIn on) then,
    though the control is present, no events are bubbled up. The OnEventBubble
    is not called in teh container either.

    In short, when I add an ASP.NET control to a templated container (thorugh
    the template or code), events do not bubble. If I added in the root of the
    control tree, they do.

    As far as I read, this should just work. But obviously, I'm missing
    something!

    Iain
    --
    Iain Downs (DirectShow MVP)
    Commercial Software Therapist
    www.idcl.co.uk
    Iain, Jun 11, 2006
    #1
    1. Advertising

  2. hi Iain, this is happening because the events are raised in the container
    control that contains instances of the controls from the inline template,
    for eg. when you do : myTemplate.InstantiateIn(somecontrol) then the events
    are fired in somecontrol, where you can either handle the events directly in
    somecontrol or you can override onBubbleEvent in somecontrol and let it pass
    up the hierarchy, in this case it will go up to the naming container
    control(the control that exposes your template), where you can again
    override onBubbleEvent letting it bubble up again(this time to the control
    that hosts your control, possibly the page) or handle it there itself,
    depending on your needs.

    Good luck,
    Alessandro Zifiglio


    "Iain" <> ha scritto nel messaggio
    news:wkhdrnn2o16w$...
    > THis is more than likely something silly I'm doing.
    >
    > (ASP.NET 2.0 W2003)
    >
    > I've written a templated databound custom control which works. Except.
    >
    > If I put a control (such as a LinkButton) in one of the templates, then no
    > event is bubble up when it is clicked.
    >
    > the control is added to teh control tree (apparently correctly).
    >
    > If I add the 'same' control to the Controls collection in code then the
    > event bubbling works correctly.
    >
    > However if instead I add the control to the Controls collection of the
    > Container for the template (the one which I call InstatiateIn on) then,
    > though the control is present, no events are bubbled up. The
    > OnEventBubble
    > is not called in teh container either.
    >
    > In short, when I add an ASP.NET control to a templated container (thorugh
    > the template or code), events do not bubble. If I added in the root of
    > the
    > control tree, they do.
    >
    > As far as I read, this should just work. But obviously, I'm missing
    > something!
    >
    > Iain
    > --
    > Iain Downs (DirectShow MVP)
    > Commercial Software Therapist
    > www.idcl.co.uk
    Alessandro Zifiglio, Jun 13, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mlimber
    Replies:
    0
    Views:
    786
    mlimber
    Aug 5, 2008
  2. Sergio Florez M.

    DataGridCommand does not bubble?

    Sergio Florez M., Nov 18, 2004, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    99
    Sergio Florez M.
    Nov 19, 2004
  3. Marc Castrechini

    Composite Control with Templates - DropDownList bubble events

    Marc Castrechini, Sep 22, 2006, in forum: ASP .Net Building Controls
    Replies:
    4
    Views:
    299
    Walter Wang [MSFT]
    Sep 29, 2006
  4. Support

    howto: bubble-up events

    Support, May 26, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    191
    Support
    May 26, 2005
  5. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    339
    Chris
    Aug 30, 2005
Loading...

Share This Page