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

Forums / Bugs & Issues / SiteMenu (i.e. RadMenu) will not replace ampersands, result: invalid markup.

SiteMenu (i.e. RadMenu) will not replace ampersands, result: invalid markup.

4 posts, 0 answered
  1. Milkman Dan
    Milkman Dan avatar
    14 posts
    Registered:
    11 Mar 2008
    18 Feb 2009
    Link to this post
    I have some ampersands (&) in my page/section titles, so when they are rendered to xhtml by the SiteMenu, the ampersands are (of course) displayed. Why is it that they come in as plain "&" characters and not the character entity reference (&)?

    This is going to prevent every single page on my site from validating. Is there a fix?
  2. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    20 Feb 2009
    Link to this post
    Hi Milkman Dan,

    Thank you for contacting us.

    I suppose you are using Sitefinity 3.2.
    You need to add this line of code into the file located at
    ~[your site]/Sitefinity/UserControls/Navigation/SiteMenu.ascx.cs.
    For version Sitefinity 3.5 location is ~[your site]/Sitefinity/UserControls/Navigation35/SiteMenu.ascx.cs
    public void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e)  
    {  
    ...  
        e.Item.Text = HttpUtility.HtmlEncode(e.Item.Text);  
    ...  

    Hope this information will help you.

    Greetings,
    Parvan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Milkman Dan
    Milkman Dan avatar
    14 posts
    Registered:
    11 Mar 2008
    24 Feb 2009
    Link to this post
    Thank you! Worked a charm, sir.

    Any particular reason that this isn't the default behavior?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    27 Feb 2009
    Link to this post
    Hello Milkman Dan,

    Thank you for getting back to us.

    The behavior with the ampersand is by design. Many clients put html in the text property and this one of the reason why nothing is rendered as entity. Generally the text property gets or sets the text caption for the menu item.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
4 posts, 0 answered