Search code examples
asp.netevent-handlingajaxcontroltoolkit

How to fire ActiveTabChanged event of ajax:Tabcontainer conditionally


I have an ajax:TabContainer on my web form and have 2 TabPanel's in TabContainer. I need to call server side methods when the user clicks on the second TabPanel. When the user clicks on first TabPanel it'll do noting and when the user clicks on the second TabPanel it'll fire some server side code.

For that I tried to use ActiveTabChanged and OnClientActiveTabChanged.

Server Side Code

void TabContainer1_ActiveTabChanged(object sender, EventArgs e)
{
    //Code goes here
}

JavaScript Code

function fireChangedEvent(sender, e) {
    if (sender.get_activeTabIndex() == 1) {
        return false;
    }
    else {
        return true;
    }
}

But it is not working every time user clicks on any tab it'll fire TabContainer1_ActiveTabChanged. Can any one guide me on how I can fire this event when I need not every time when the user clicks on any tab?


Solution

  • Finally I found a solution of this problem. We can use update panel and triggers for conditional calling of server side method. Solution posted by Matt Berseth

    How To: Lazy-load TabPanel's within the AjaxControlToolkit's TabContainer Control

    Now my problem is solved.