+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / SiteTabStrip and InnermostSelectedTab is null

SiteTabStrip and InnermostSelectedTab is null

4 posts, 1 answered
  1. Milos Tadic
    Milos Tadic avatar
    32 posts
    Registered:
    05 Nov 2009
    03 Dec 2010
    Link to this post
    Hi folks,

    I have a little problem with main navigation (using rad tabstrip).
    Actually I need function on mouse out.

    Now I'm using this function:

    <script type="text/javascript" language="javascript">
                function SelectMyTab(sender, eventArgs) {
                    var tab = eventArgs.get_tab();
                    tab.select();
                }
     
                function UnSelectMyTab(e) {
                    var tabStrip = $find('<%= RadTabstrip1.ClientID%>');
                    if (!tabStrip) return;
                    //Find the element which the mouse is over
                    var destElement = e.relatedTarget || e.toElement;
                    if ($telerik.isDescendant(tabStrip.get_element(), destElement))
                        return;
                    var initialTab = tabStrip.findTabByText(tabStrip.get_attributes().getAttribute("InitialTab"));
                    initialTab.unselect();
                    initialTab.selectParents();
                }
            </script>
        
        
       
    <telerik:RadTabStrip ID="RadTabstrip1" runat="server" UnSelectChildren="True" OnClientMouseOver="SelectMyTab"
                OnMouseOut="UnSelectMyTab(event)" ClickSelectedTab="True" SelectedIndex="0" AutoPostBack="True"></telerik:RadTabStrip>

    Code-behind:
    protected void Page_Load(object sender, EventArgs e)
        {
            //RadTabstrip1.Attributes["InitialTab"] = "Home";
            RadTabstrip1.Attributes["InitialTab"] = RadTabstrip1.InnermostSelectedTab.Text;
     
        }

    But, problem is that InnermostSelectedTab always is null. I don't know how to get name of current tab.
    Any suggestion will be helpful how can I resolve problem.

    Thanks.

    Best regards,
    Milos.
  2. Milos Tadic
    Milos Tadic avatar
    32 posts
    Registered:
    05 Nov 2009
    06 Dec 2010
    Link to this post
    Anyone?

    Thanks,
    Milos.
  3. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    07 Dec 2010
    Link to this post
    Hello Milos Tadic,

    Can you please show us how you handle the selecting of tabs when the page is loaded and how you bind the tab. The problem is that either the tab strip is empty (not bound yet) when you call the InnermostSelectedTab or you are not persisting tab selection. You can see how we handle data population and selecting tabs in the SiteTabStrip control (~/Sitefinity/UserControls/Navigation35/SiteTabstrip.ascx.cs)

    Best wishes,
    Radoslav Georgiev
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
    Answered
  4. Milos Tadic
    Milos Tadic avatar
    32 posts
    Registered:
    05 Nov 2009
    07 Dec 2010
    Link to this post
    Hi Radoslav, thank you for reply.
    My mistake because I put code on top of page load (where tab is empty).
    That was wrong

    protected void Page_Load(object sender, EventArgs e)
        {
     
            //if (RadTabstrip1.SelectedTab != null)
            //{
            //CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode;
            //if (node != null)
            //{
            //string URLpomocna = Request.Url.AbsoluteUri.ToString();
            //if (URLpomocna.Contains("default.aspx") == true)
            //{
            //    RadTabstrip1.Attributes["InitialTab"] = "Home";
            //}
            //else if (URLpomocna.Contains("test") == true)
            //{
            //    RadTabstrip1.Attributes["InitialTab"] = "Ishrana";
            //}
            //}
            //RadTabstrip1.Attributes["InitialTab"] = RadTabstrip1.InnermostSelectedTab.Text;
            //}
            //Response.Write(RadTabstrip1.SelectedTab.UniqueID);
            
            if (this.ShowOnlyFirstLevel)
            {
                SiteMapNode rootNode = SiteMap.RootNode;
                foreach (SiteMapNode node1 in rootNode.ChildNodes)
                {
                    RadTab tab = new RadTab();
                    tab.Text = node1.Title;
                    tab.NavigateUrl = node1.Url;
                    this.RadTabstrip1.Tabs.Add(tab);
                    
                }
                
                 
                CmsSiteMapNode currentNode = SiteMap.CurrentNode as CmsSiteMapNode;
     
                if (currentNode != null && currentNode.ParentNode != null)
                {
                    while (currentNode.ParentNode != rootNode)
                    {
                        CmsSiteMapNode tempNode = currentNode.ParentNode as CmsSiteMapNode;
                        if (tempNode == null)
                            break;
                        currentNode = tempNode;
                    }
                    RadTab item = this.RadTabstrip1.FindTabByUrl(this.ResolveUrl(currentNode.Url));
                    if (item != null)
                    {
                        // here you can set the style for the top-level item  
                        item.Selected = true;
                    }
                }
                else if (this.RadTabstrip1.Tabs.Count > 0)
                {
                    this.RadTabstrip1.Tabs[0].Selected = true;
                }
            }
            else
            {
                SiteMapNode root = this.GetStartingNode();
                FillTabStrip(root, this.RadTabstrip1.Tabs, 0);
            }
            RadTabstrip1.Attributes["InitialTab"] = RadTabstrip1.InnermostSelectedTab.Text;
        }

    Now, everything works.

    Thank you again.

    Best regards,
    Milos.
Register for webinar
4 posts, 1 answered