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

Forums / Developing with Sitefinity / How to add "Site Menu" control via API?

How to add "Site Menu" control via API?

3 posts, 1 answered
  1. Gilbert van Ooijen
    Gilbert van Ooijen avatar
    6 posts
    Registered:
    27 Aug 2009
    28 Sep 2009
    Link to this post

    Hi,

    I am building a conversion tool to migrate our old CMS data to Sitefinity 3.7. I have already created the pages with the correct hierarchical structure. I also added some Generic Content controls to the pages like this:

    1     var cmsManager = new CmsManager();  
    2  
    3     try 
    4     {  
    5         var newControl = new Telerik.Cms.Engine.WebControls.GenericContent();  
    6           
    7         newControl.ID = sm3Content.Id.ToString();  
    8         newControl.Content = sm3Content.Text;  
    9  
    10         try 
    11         {  
    12             sfPage = (ICmsPage)cmsManager.GetPage(sfPage.ID, true);  
    13             IStagedPage stagedPage = sfPage.Staged;  
    14  
    15             stagedPage.AddControl("content", newControl);  
    16         }  
    17         catch (Exception ex)  
    18         {  
    19             Debug.Assert(ex != null);  
    20             throw;  
    21         }  
    22     }  
    23     catch (Exception ex)  
    24     {  
    25         MigrationLogger.PublishInternalException(ex, true);  
    26     } 


    So the Generic Content Module can be found in the Telerik.Cms.Engine.WebControls.GenericContent namespace. Now I want to add a menu control to each page. The "Site Menu" control which you can find in the UI under "Navigation". But I don't know in which namespace to find the proper control in the Sitefinity object model. Can you help me out?

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    28 Sep 2009
    Link to this post
    Hello Gilbert van Ooijen,

    You can use RadMenu control - Telerik.Web.UI.RadMenu. SiteMenu control is a UserControl that located under Sitefinity/UserControls/Navigation35 folder of each Sitefinity project. In this case you can use the overload of stagedPage.AddControl as shown below:

    stagedPage.AddControl(containerID, controlUrl, ControlID); 

    I hope this helps.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
  3. Gilbert van Ooijen
    Gilbert van Ooijen avatar
    6 posts
    Registered:
    27 Aug 2009
    28 Sep 2009
    Link to this post
    Thanks Ivan, this is exactly what I was looking for. :-)
Register for webinar
3 posts, 1 answered