menu doesn't escape ampersands

6 posts, 0 answers
  1. SelAromDotNet
    SelAromDotNet avatar
    67 posts
    Member since:
    Jul 2012

    Posted 06 Jan 2009 Link to this post

    I'm having trouble with the rad menu in the latest sitefinity (3.5 sp1) where the links are not correctly escaping the ampersand (&) symbols in my link text. Take a look here: http://www.mcallen.net/golf/home.aspx. the menu up at the top under driving range (Fees & Memberships) and Contact Us (Maps & Directions) have ampersands, but they are not escaped to & by the menu. I tried manually chaning the link text and putting the full escaped text myself, but it still shows up as &.

    can someone tell me what I'm doing wrong?

    thanks!
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 07 Jan 2009 Link to this post

    Hi SelArom,

    This is by design - the text of the menu items is not html encoded. The same behavior can be observed by the built-in ASP.NET menu control and the HyperLink control.

    You should replace the"&" in the text of the items with "&":

    foreach (RadMenuItem item in RadMenu1.GetAllItems())
    {
       item.Text = item.Text.Replace("&", "&");
    }

    Regards,
    Albert
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. SelAromDotNet
    SelAromDotNet avatar
    67 posts
    Member since:
    Jul 2012

    Posted 07 Jan 2009 Link to this post

    thank you for your prompt reply! is there a reason this doesn't happen by default?
  5. SelAromDotNet
    SelAromDotNet avatar
    67 posts
    Member since:
    Jul 2012

    Posted 07 Jan 2009 Link to this post

    wait, this isn't working. I'm assuming that this code goes in the page_load method? I've done this, but the text is still coming out unescaped...
  6. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 07 Jan 2009 Link to this post

    Hello SelArom,

    Perhaps the menu is populated later than Page_Load. You can try setting the text later - during Page_PreRender for example.

    Regards,
    Albert
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. SelAromDotNet
    SelAromDotNet avatar
    67 posts
    Member since:
    Jul 2012

    Posted 07 Jan 2009 Link to this post

    oops my mistake for some reason I put it in preinit. not sure how that happened! I moved it to page load and now it works fine, thanks!

    any plans to make this the default behavior?

    thanks again!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017