More in this section

Forums / Developing with Sitefinity / Open Menu Item in New Window Error

Open Menu Item in New Window Error

2 posts, 1 answered
  1. Cameron
    Cameron avatar
    42 posts
    Registered:
    27 Jul 2009
    19 Feb 2010
    Link to this post
    If I made the change as posted in http://www.sitefinity.com/support/forums/sitefinity-3-x/developing-with-sitefinity/menu-link-opens-in-a-new-window.aspx ,
    I get the cmsNode text turn red and "The name cmsNode does not exist in the current context."

    I am changing FROM:

    public void RadPanelbar1_ItemDataBound(object sender, RadPanelBarEventArgs e)
        {
            if (this.hideUrlForGroupPages)
            {
                CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode;
                if (node != null && node.PageType == CmsPageType.Group)
                {
                    e.Item.NavigateUrl = "";
                     
                }
                 
            }
      
          
        }

        
    changing TO:    
        
    public void RadPanelbar1_ItemDataBound(object sender, RadPanelBarEventArgs e)
       {
           if (this.hideUrlForGroupPages)
           {
               CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode;
               if (cmsNode != null && cmsNode.CmsPage.PageType == CmsPageType.External)
               {
                   e.Item.Attributes.Add("onclick", "window.open('" + cmsNode.CmsPage.ExternalUrl + "')");
                   e.Item.NavigateUrl = "";
               }
               if (node != null && node.PageType == CmsPageType.Group)
               {
                   e.Item.NavigateUrl = "";
                    
               }
                        
           }
                           
       }

        
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Feb 2010
    Link to this post
    Hello Michael Buchsbaum,

     cmsNode should be CmsSiteMapNode. In your code you have not declared an object of this type. Also your code will work only in case that you are hiding url of a group page.

    Best wishes,
    Ivan Dimitrov
    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
2 posts, 1 answered