문제

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
                };
도움이 되었습니까?

해결책

%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>";
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top