How to Pre-select a tab in Microsoft.Web.UI.WebControls tabstrip

Last post 10-06-2009 5:51 AM by hfrmobile. 4 replies.

Sort Posts:

  • How to Pre-select a tab in Microsoft.Web.UI.WebControls tabstrip

    10-27-2005, 2:19 AM
    • Member
      50 point Member
    • xtreme
    • Member since 08-08-2005, 9:51 AM
    • Posts 10
    Is it possible to pre-select a tab when u call a page from a different page. For example i need to select the 3rd tab when the page loads..
  • Re: How to Pre-select a tab in Microsoft.Web.UI.WebControls tabstrip

    11-03-2005, 2:41 PM
    • Member
      368 point Member
    • Marnee
    • Member since 06-17-2005, 8:38 PM
    • Tucson
    • Posts 76
    Yes, this is very simple.

    In the Page Load routine (in VB this is Private Sub Page_Load) do somthing like this:

    Tabstrip.SelectedIndex = TabIndex

    (TabIndex is of course an integer)
    A is A
  • Re: How to Pre-select a tab in Microsoft.Web.UI.WebControls tabstrip

    11-04-2005, 9:38 PM
    • Member
      50 point Member
    • xtreme
    • Member since 08-08-2005, 9:51 AM
    • Posts 10
    Thanx Marnee.... it works..
  • Re: How to Pre-select a tab in Microsoft.Web.UI.WebControls tabstrip

    11-22-2005, 3:10 PM
    Is there a way of controlling the selected index from the client side?  I tried this and it doesn't seem to work...

    function changeTab() { }   <script language=jscript>
        function changeTab() {
          <!--
           var tabStrip = document.Form1.elements['ucActForm1:tabProducts'];
           var selIndex = tabStrip.SelectedIndex;
           
           if (selIndex == 0)
           {
            tabStrip.SelectedIndex(1);
           }
          -->
        }
      </script>
  • Re: How to Pre-select a tab in Microsoft.Web.UI.WebControls tabstrip

    10-06-2009, 5:51 AM
    • Member
      6 point Member
    • hfrmobile
    • Member since 09-15-2009, 3:29 AM
    • Austria
    • Posts 3

    OK, works but makes the code difficult to read if you see: MyTabStrib.SelectedIndex = 4; Also if there will be changes in the future (new tab or hiding/showing tabs dynamically) the resulting code will be difficult to maintain.


    MyTabs.ShowTab("HistoryTab");


    e.g. (pseudo-code from Refelctor)

    public bool ShowTab(string tabID)
    {
    int tabCount = 0;

    for (int i = 0; i < this.get_Items().Count; i++)
    {
    if (this.get_Items().get_Item(i).GetType() == typeof(Tab))
    tabCount++;

    if (this.get_Items().get_Item(i).get_ID() == tabID)
    {
    base.set_SelectedIndex(tabCount - 1);
    return true;
    }
    }

    return false;
    }




Page 1 of 1 (5 items)