get current tab client side

3 posts, 1 answers
  1. Alan T
    Alan T avatar
    125 posts
    Member since:
    Apr 2010

    Posted 21 Jul 2011 Link to this post

    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. Answer
    Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 21 Jul 2011 Link to this post

    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:

    http://www.telerik.com/help/aspnet-ajax/tabstrip-client-side-radtabstrip.html

    I hope that helps.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alan T
    Alan T avatar
    125 posts
    Member since:
    Apr 2010

    Posted 26 Jul 2011 Link to this post

    thankyou very much.

    Alan
Back to Top