views:

1450

answers:

2

I am stuck working with the TabContainer control of the Ajax Contol Toolkit.

When a user clicks a tab, I am trying to capture which tab was clicked (like the index).

Anyone out there know if this is possible?

A: 

The stupid question is: why do you need to know this??

I'm using the TabContainer in the Ajax Control Toolkit myself, too - but I've never felt the urge to know when which tab was clicked. The TabContainer will show the appropriate page, and the user can interact with the controls on that tab page - why do you need to know what page was activated? What's your scenario?

Checking out the Ajax Control Toolkit website show a few properties of interest:

  • ActiveTabChanged (Event) - Fired on the server side when a tab is changed after a postback
  • OnClientActiveTabChanged - The name of a javascript function to attach to the client-side tabChanged event
  • ActiveTabIndex - The first tab to show

Could you tap into either the ActiveTabChanged or OnClientActiveTabChanged event to achieve what you're looking for??

Marc

marc_s
Well, the stupid answer is that I wanted to actually have the last tab in the list be a button that when clicked would dynamically add a new tab. So instead of just displaying the content, I wanted change the behavior of the click event for a particular tab. I ended up just making a button that lives outside the tab control and it works fine. But I would still be curious how to achieve this behavior. It seems like an "Add New Tab" button next to the last tab would be a feature.
Mike M
So can you hook into the "OnClientActiveTabChanged" javascript event then and handle this case?
marc_s
I never tried the client side. Even if it did give me a nice way to determine which tab was clicked, I didn't want to have to go client side and THEN post to server. Just too messy for my taste. Moving the button works fine for now.
Mike M
A: 

The server side event ActiveTabChanged works fine. Just make sure to set AutoPostBack to "true"

Ranch