Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

The following code is adding extra %22 after the aspx which cause link to fail.

XmlElement p = new XmlDocument().CreateElement("p");
p.InnerText = @"<table style=""width: 100%""><tbody>
                                <tr><td>&#160;<a href=" + web.Url + @"/Lists/Jr/AllItems.aspx"">J & R</a></td></tr>
                                <tr><td>&#160;<a href=" + web.Url + @"/SalesStatus/Forms/AllItems.aspx"">Sales Status</a></td></tr> </tbody></table>";
                ContentEditorWebPart cewp = new ContentEditorWebPart
                    Content = p
share|improve this question

1 Answer 1

up vote 2 down vote accepted

%22 is code for quote (").

This is because you forgot to add a starting quote. I mean, if, for example, web.Url is equal to http://localhost, final html will be:

<a href=http://localhost/Lists/Jr/AllItems.aspx">J & R</a>

This html is not correct, so sharepoint "fixes" it, replacing " with %20.

You should provide starting quote as well as the ending one, as follows:

p.InnerText = @"<table style=""width: 100%""><tbody>
                <tr><td>&#160;<a href=""" + web.Url + @"/Lists/Jr/AllItems.aspx"">J & R</a></td></tr>
                <tr><td>&#160;<a href=""" + web.Url + @"/SalesStatus/Forms/AllItems.aspx"">Sales Status</a></td></tr> </tbody></table>";
share|improve this answer
You are a SPHero.... Thanks for your help... Monica – Monica Contera May 21 '11 at 13:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.