我一直在寻找,但我无法找到有助于我的信息。
我有这个字符串变量,其中包含一堆HTML(标签,文本和图像链接),我想知道如何将该字符串转换为某种HTML支持的类型,以显示在我的应用程序中,以便它出现图像和文本以粗体显示,而不仅仅是带有标记的纯文本。
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td colspan="3">
<h2>
<img src="https://www.iseg.ulisboa.pt/aquila/getFile.do?method=getFile&fileId=682501" alt="" width="745" height="497" />
</h2>
</td>
</tr>
<tr>
<td colspan="3">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<h3>
<a href="https://onedrive.live.com/redir?resid=21016A3C1649D3A2!4589&authkey=!ACVZ-u-igsIFDLs&ithint=folder%2cjpg">> Reportagem Fotográfica (7 de Março)</a>
<br />
<a href="https://onedrive.live.com/redir?resid=21016A3C1649D3A2!4738&authkey=!AJbBcUJpWxqtP3g&ithint=folder%2cjpg">> Reportagem Fotográfica (9 de Março)</a></h3>
</td>
</tr>
<tr>
<td>
<h6>Decorrem nos dias 7 e 9 de Março as Cerimónias de Entrega de Diplomas de Pós-Graduação, no Auditório CGD.
<br />Contaram com momentos musicais de Manuel Rebelo e João Gil. Mais uma vez, parabéns a todos os diplomados!</h6>
<h6> </h6>
<p> </p>
<p> </p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
答案 0 :(得分:2)
您可以使用WebBrowser
控件来处理此问题,然后通过StoreLocatorController : UmbracoAuthorizedApiController // this allows only logged in users to call the api and also ensures that the correct umbraco context is set
{
public string basePath;
public StoreLocatorController()
{
this.basePath = System.Web.Hosting.HostingEnvironment.MapPath(@"/App_Data/storeLocatorUpload/");
}
[HttpPost]
public void Go()
{
var myContext = Request.TryGetHttpContext();
if (myContext.Success)
{
HttpPostedFileBase myFile = myContext.Result.Request.Files["file"];
if (myFile == null)
{
throw new HttpException("invalid file");
}
// save the file
myFile.SaveAs(this.basePath + "file.ext");
UmbracoDatabase db = ApplicationContext.DatabaseContext.Database;
// parse the data and insert them using UmbracoDatabase db
//..
}
}
}
方法将其内容显式设置为HTML字符串:
NavigateToString()
如果这不能满足您的需求,您可以使用第三方控件,例如this HtmlRenderer available via NuGet,这听起来可能正是您所寻找的。 p>