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

Forums / Developing with Sitefinity / create dead links

create dead links

11 posts, 1 answered
  1. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    01 Sep 2009
    Link to this post
    I need to create some dead links on my sitemenu.
    eg. test.aspx#

    Another URL doesn't allow to add #.
    How can I add # for some links?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    01 Sep 2009
    Link to this post
    Hello Rabindra,

    Since Sitefinity's RadMenu is bound to CmsSiteMapDataSource by default, you can add the following logic in Page_Load event of SiteMenu(RadMenu) control.

     protected void Page_Load(object sender, EventArgs e) 
        { 
            RadMenu1.DataBind(); 
            RadMenuItemCollection mCollection1 = RadMenu1.Items; 
            foreach (RadMenuItem mItem in mCollection1) 
            { 
                if(mItem.Text.Equals("DeadLink")) 
                { 
                    mItem.NavigateUrl=""
     
                } 
            } 

    You can expose a public property for "DeadLink" so that you can control which item/items will not be clickable through Sitefinity's ControlDesigner UI.

    Regards,
    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.
  3. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    02 Sep 2009
    Link to this post
    hi Ivan,
       I used RadMenu which is in CMS. I added this Radmenu in my mastertemplate.
    I didn't code anything.
    Did you mean I should add that code in codebehind page of my masterpage?

    Also i know very little programming. How can I expose a public property for "DeadLink" ?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    02 Sep 2009
    Link to this post
    Hi Rabindra,

    "you can add the following logic in Page_Load event of SiteMenu(RadMenu) control." SiteMenu control can be found under Sitefinity/UserControls/Navigation35. As written above you can use a custom user control.

    Greetings,
    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.
  5. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    02 Sep 2009
    Link to this post
    sorry...I was using Site Menu...

    wil that code work for Site Menu as well?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    02 Sep 2009
    Link to this post
    Hello Rabindra,

    Yes it will work. Please read the previous post carefully because we are going into loops:
    "SiteeMenu control can be found under Sitefinity/UserControls/Navigation35."

    Greetings,
    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.
  7. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    02 Sep 2009
    Link to this post
    I added following code in page load event but it didn't work. I can still click on Planning.aspx page. Do I have to change the SiteMenu's ID to RadMenu1 by going to edit>Misc>ID?
            RadMenu1.DataBind();  
            RadMenuItemCollection mCollection1 = RadMenu1.Items;  
            foreach (RadMenuItem mItem in mCollection1)  
            {  
                if(mItem.Text.Equals("Planning"))  
                {  
                    mItem.NavigateUrl="#";  
      
                }  
            }  

  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    02 Sep 2009
    Link to this post
    Hello Rabindra,

    If you attached the code to debugger does it get inside the loop? Check how many items are in the collection. The code should work without problems.

    Sincerely yours,
    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.
  9. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    06 Sep 2009
    Link to this post
    Hi Ivan,
       I put a breakpoint and found that it is only looking for the first level menu items.
    I wanted to put deadlinks for second level menu items. How do I do that?



  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    06 Sep 2009
    Link to this post
    Hello Rabindra,

    RadMenu.Items returns object that contains root items of the current RadMenu control.

    Try using the code below:

            RadMenu1.DataBind(); 
            IList<RadMenuItem> mCollection1 = RadMenu1.GetAllItems(); 
            foreach (RadMenuItem mItem in mCollection1) 
            { 
                if(mItem.Text.Equals("DeadLink")) 
                { 
                    mItem.NavigateUrl=""
     
                } 
            } 


    Best wishes,
    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
  11. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    07 Sep 2009
    Link to this post
    thanks Ivan.
    At first I was using Radmenu1.items[1].item but your solution worked great.
    I am using Switch Case instead of If statements.
Register for webinar
11 posts, 1 answered