Pregunta

El siguiente código está agregando un %22 adicional después del ASPX que hace que el enlace falle.

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
                };
¿Fue útil?

Solución

%22 es código para cotización (").

Esto se debe a que olvidaste agregar una cita inicial. Quiero decir, si, por ejemplo, Web.url es igual a http://localhost, HTML final será:

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

Este HTML no es correcto, por lo que SharePoint lo "soluciona", reemplazando " con %20.

Debe proporcionar una cita inicial, así como la final, como sigue:

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>";
Licenciado bajo: CC-BY-SA con atribución
scroll top