Event Bubbling From The HeaderTemplate

Discussion in 'ASP .Net Web Controls' started by Nathan Sokalski, Sep 21, 2005.

  1. I have three LinkButtons in the HeaderTemplate of my DataList (I use them to
    let the user determine what to sort the list by). I am assuming that the
    event will be bubbled to the ItemCommand event (since that is the default
    and I did not supply a CommandName). However, I need to determine which of
    the three LinkButtons triggered the event. How can I do this? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
    Nathan Sokalski, Sep 21, 2005
    #1
    1. Advertising

  2. Nathan Sokalski

    Brock Allen Guest

    It's the 'sender' parameter in the event handler.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen

    > I have three LinkButtons in the HeaderTemplate of my DataList (I use
    > them to let the user determine what to sort the list by). I am
    > assuming that the event will be bubbled to the ItemCommand event
    > (since that is the default and I did not supply a CommandName).
    > However, I need to determine which of the three LinkButtons triggered
    > the event. How can I do this? Thanks.
    >
    Brock Allen, Sep 22, 2005
    #2
    1. Advertising

  3. Sorry to burst your Event Bubble, but that is incorrect. First of all, the
    ItemCommand uses "source", not "sender". Second, the value of "source" will
    always be the DataList that the event was bubbled from, not the control that
    triggered the event. One thing that I noticed, I haven't had time to look
    into it yet, but while I was testing some other code of mine that uses event
    bubbling, I noticed that in the Trace information there is a value (I don't
    know if it's a variable or not) called __EVENTTARGET which has the value of
    the control which triggered the event bubbling. If Trace can get at this
    value, I was wondering if there might be a way to get at it through some
    kind of system variable? If anyone knows anything about this, I would like
    to know. Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Brock Allen" <> wrote in message
    news:...
    > It's the 'sender' parameter in the event handler.
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >> I have three LinkButtons in the HeaderTemplate of my DataList (I use
    >> them to let the user determine what to sort the list by). I am
    >> assuming that the event will be bubbled to the ItemCommand event
    >> (since that is the default and I did not supply a CommandName).
    >> However, I need to determine which of the three LinkButtons triggered
    >> the event. How can I do this? Thanks.
    >>

    >
    >
    Nathan Sokalski, Sep 23, 2005
    #3
  4. Nathan Sokalski wrote:
    > I have three LinkButtons in the HeaderTemplate of my DataList (I use them to
    > let the user determine what to sort the list by). I am assuming that the
    > event will be bubbled to the ItemCommand event (since that is the default
    > and I did not supply a CommandName). However, I need to determine which of
    > the three LinkButtons triggered the event. How can I do this? Thanks.


    Can't you set the ItemCommand for the LinkButtons? This will still
    raise the DataList's ItemCommand event, and you can do:

    If e.CommandName = "..." Then
    ...
    ElseIf e.CommandName = "..." Then
    ...
    ElseIf e.CommandName = "..." Then
    ...
    End If


    Where "..." is the ItemCommand values for the various LinkButtons.

    --

    Scott Mitchell [ASP.NET MVP]

    http://www.4GuysFromRolla.com/ScottMitchell
    Scott Mitchell [MVP], Sep 23, 2005
    #4
    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. Nathan Sokalski

    Event Bubbling From The HeaderTemplate

    Nathan Sokalski, Sep 21, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    407
    Scott Mitchell [MVP]
    Sep 23, 2005
  2. Nathan Sokalski

    Event Bubbling and the ItemCommand Event

    Nathan Sokalski, May 29, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    406
    Nathan Sokalski
    May 29, 2006
  3. Nathan Sokalski

    Event Bubbling From The HeaderTemplate

    Nathan Sokalski, Sep 21, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    116
    Scott Mitchell [MVP]
    Sep 23, 2005
  4. Nathan Sokalski

    Event Bubbling and the ItemCommand Event

    Nathan Sokalski, May 29, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    140
    Nathan Sokalski
    May 29, 2006
  5. Nathan Sokalski

    Event Bubbling and the ItemCommand Event

    Nathan Sokalski, May 29, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    142
    Nathan Sokalski
    May 29, 2006
Loading...

Share This Page