This is a migrated thread and some comments may be shown as answers.

get current tab client side

2 Answers 606 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Alan T
Top achievements
Rank 1
Alan T asked on 21 Jul 2011, 06:15 PM
Hi i have a tab strip & a number of page views associated with it.

what i've also got is some .net buttons which allow the user to also navigate through the tabs if they wish, like a next and previous.

I'd like to disable the previous button when the user is on the first tab and disable the next button when they're on the last tab.

hopefully that makes sense, i want to do this without having to do a postback which i'm sure is possible.

I suppose it would be some code that goes into the buttons Enabled attribute, something like Enabled=' if currenttab = firsttab then false else true' in the example of the 'previous' button.

Many thanks

Alan

2 Answers, 1 is accepted

Sort by
0
Accepted
Kevin
Top achievements
Rank 2
answered on 21 Jul 2011, 06:55 PM | edited on 08 Jan 2024, 11:08 AM
Hello Alan,

To do this, you will need to create handle two events: OnClientTabSelected (RadTabStrip) and OnClientClicked (RadButton) or onclick (Button), depending on the button control you're using.

Either way, you would use the same method in both events (I'm using RadButton in the example):

function ToggleNextPreButtons() {
    var tabStrip = $find("<%=RadTabStrip1.ClientID%>");
    var selectedTab = tabStrip.get_selectedTab();
  
    // get previous button and toggle enabled state based on tab index (0 - Disabled, Not 0 - Enabled)
    var prevButton = $find("<%=RadButton1.ClientID%>");
    prevButton.set_enabled(selectedTab.get_index() != 0);
  
    // get next button and toggle enabled state based on tab index (Not equal tab count - Disabled, Equal tab count - Enabled)
    var nextButton = $find("<%=RadButton2.ClientID%>");
    nextButton.set_enabled(selectedTab.get_index() != tabStrip.get_tabs().get_count()-1);
}

You can refer to this help topic on how to do the navigation stuff:

https://docs.telerik.com/devtools/aspnet-ajax/controls/tabstrip/client-side-programming/objects/radtabstrip-object 

I hope that helps.
0
Alan T
Top achievements
Rank 1
answered on 26 Jul 2011, 03:45 PM
thankyou very much.

Alan
Tags
TabStrip
Asked by
Alan T
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Alan T
Top achievements
Rank 1
Share this question
or