This is a migrated thread and some comments may be shown as answers.

menu doesn't escape ampersands

5 Answers 92 Views
Menu
This is a migrated thread and some comments may be shown as answers.
SelAromDotNet
Top achievements
Rank 2
SelAromDotNet asked on 06 Jan 2009, 09:56 PM
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!

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 07 Jan 2009, 07:39 AM
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.
0
SelAromDotNet
Top achievements
Rank 2
answered on 07 Jan 2009, 02:36 PM
thank you for your prompt reply! is there a reason this doesn't happen by default?
0
SelAromDotNet
Top achievements
Rank 2
answered on 07 Jan 2009, 02:40 PM
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...
0
Atanas Korchev
Telerik team
answered on 07 Jan 2009, 02:48 PM
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.
0
SelAromDotNet
Top achievements
Rank 2
answered on 07 Jan 2009, 03:15 PM
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!
Tags
Menu
Asked by
SelAromDotNet
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
SelAromDotNet
Top achievements
Rank 2
Share this question
or