Get selected Index of radtab Strip

5 posts, 1 answers
  1. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 06 Feb 2014 Link to this post

    I am trying to do validation on my multiPages which are part of my radtabStrip on each click of the radtab.  I am trying to the get the selected index of each tab so that I know which one I am on to do the validation.

    I must say I give the new site and F, what a frustrating new site.

    <telerik:RadTabStrip ID="radESGRTab" runat="server" Orientation="HorizontalTop" MultiPageID="radPageMulti" ClickSelectedTab="true" Skin="Web20" Font-Bold="true" Font-Size="Large" Width="800px" OnClientMouseOver="tabEmployer" OnClientTabSelected="CheckValidation">
                  <Tabs>
                      <telerik:RadTab PageViewID="rdPageInfo" Text="Soldier Info" runat="server" SelectedIndex="1"></telerik:RadTab>
                      <telerik:RadTab PageViewID="rdPageEmploy" Text="Employer Info" runat="server" SelectedIndex="2"></telerik:RadTab>
                      <telerik:RadTab PageViewID="rdpageSurvey" Text="Survey Info" SelectedIndex="3"></telerik:RadTab>
                      <telerik:RadTab PageViewID="rdPageAwards" Text="Employer Awards" SelectedIndex="4"></telerik:RadTab>
                  </Tabs>
              </telerik:RadTabStrip>



    function CheckValidation() {
               var tab1 = $find('<%=radESGRTab.ClientID %>').selectedIndex();
                
               if (tab1 == 1) {
                   var combo = $find('<%= ddlSoldCounty.ClientID %>');
                   var item = combo.get_selectedItem().get_value();
                   alert(combo.get_selectedItem().get_value());
                   if (item == 1) {
                       alert('You must pick a county from Drop Down List');
                   }
               }
           }
       </script>
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Feb 2014 in reply to Kevin Link to this post

    Hi Kevin,

    The RadTabStrip supports zero based index of the selected tab. The default value is -1 if no child tab is selected. Please have a look into the following modification I did in your code to get the index of the selected tab.

    ASPX:
    <telerik:RadTabStrip ID="radESGRTab" runat="server" Orientation="HorizontalTop" MultiPageID="radPageMulti"   ClickSelectedTab="true" Skin="Web20" Font-Bold="true" Font-Size="Large" Width="800px" OnClientTabSelected="CheckValidation">
        <Tabs>
            <telerik:RadTab PageViewID="rdPageInfo" Text="Soldier Info" runat="server" SelectedIndex="0">
            </telerik:RadTab>
            <telerik:RadTab PageViewID="rdPageEmploy" Text="Employer Info" runat="server" SelectedIndex="1">
            </telerik:RadTab>
            <telerik:RadTab PageViewID="rdpageSurvey" Text="Survey Info" SelectedIndex="2">
            </telerik:RadTab>
            <telerik:RadTab PageViewID="rdPageAwards" Text="Employer Awards" SelectedIndex="3">
            </telerik:RadTab>
        </Tabs>
    </telerik:RadTabStrip>

    JavaScript:
    <script type="text/javascript">
        function CheckValidation(sender, args) {
            alert(sender.get_selectedIndex());
        }
    </script>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 07 Feb 2014 in reply to Shinu Link to this post

    awesome thank you much.
  5. Subin das
    Subin das avatar
    1 posts
    Member since:
    Dec 2015

    Posted 21 Dec 2015 in reply to Shinu Link to this post

    Hi Shinu,

         I need to get or set the rad tab selected index on ASP button OnClientClick.

    I tried the this code "$find('<%=radESGRTab.ClientID %>').selectedIndex();" But am getting the following error

    "Object doesn't support property or method 'selectedIndex"

    can you please help me on this

     

    Thanks

    Subin

     

     

     

  6. Ivan Danchev
    Admin
    Ivan Danchev avatar
    835 posts

    Posted 24 Dec 2015 Link to this post

    Hello Subin,

    The right client-side method to use in order to get the TabStrip's selected index is: get_selectedIndex()

    Regards,
    Ivan Danchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017