Justin C
Justin C

Reputation: 1924

catch SelectedIndexChanged event of Accordion control in ASP.NET AjaxToolkit

I have an Accordion control that is populated dynamically. I want to catch the event raised when a new pane is clicked on to open. I don't see the event at all in intelli-sense and when I code it by hand anyways I get errors.

Is there any way to catch this event?

The goal is to let a control in the masterpage that is holding the Accordion know when the Accordion has changed so it can update another control.

Upvotes: 3

Views: 7453

Answers (1)

Frédéric Hamidi
Frédéric Hamidi

Reputation: 262979

To handle the client-side selectedIndexChanged event:

function pageLoad()
{
    $find("accordionBehaviorID").add_selectedIndexChanged(
        accordion_selectedIndexChanged);
}

function accordion_selectedIndexChanged(sender, args)
{
    var oldIndex = args.get_oldIndex();
    var newIndex = args.get_selectedIndex();

    // Do something...
}

As usual, you can define and register the handler at the same time using an anonymous function:

function pageLoad()
{
    $find("accordionBehaviorID").add_selectedIndexChanged(
        function(sender, args) {
            // Do something...
        }
    );
}

Upvotes: 5

Related Questions