服务为我提供了包含HTML标签的签名值,例如
<html><body>..
我需要在UI上显示这个,据我所知最好的方法是@Html.Raw
。我正在开展一个保密项目,这就是为什么我需要小心在线分享它。
使用@Html.Raw
时,我遇到了这个特殊问题。以下是我的示例代码
<table>
<tr>
<td>
<div>
<input>
My Signature<br/>
<span>@Html.Raw(Model.MyHtmlSignature)/span>
</div>
</td>
</tr>
</table>
在Model.MyHtmlSignature
我收到服务中的数据
<table border=0 cellspacing=0 cellpadding=0 style='mso-padding-alt:0in 0in 0in 0in'>
<tr>
<td width=289 valign=top style='width:216.75pt;padding:0in 0in 0in 0in'>
<table border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=289 valign=top style='width:216.75pt;padding:0in 0in 0in 0in'>
<span style='font-size:11.0pt;font-family:Arial'><br>____________________________________<br>
Ziggler Warted</span>
</td>
</tr>
</table>
</td>
</tr>
</table>
我需要在UI上看到如下。
__
Ziggler Warted
[水平线和人的下一行名称]
当我使用@Html.Raw
时,当我鼠标点击我的表单时,我会看到下面的某种边框。
有人有这个问题吗?
更新
我们对此进行了讨论,现在服务团队正在返回如下所示的签名,并从中提取正文并使用@ Html.Raw(Model.FormattedSignature)在UI上显示
<html>
<head></head>
<body style="font-family: Tahoma; font-size: 10pt;" contenteditable="true">
<p style="margin-top: 8px; margin-bottom: 0px;">
<font size="2"> </font>
</p>
<p style="margin-top: 8px; margin-bottom: 0px;">
<font size="2">___________________________</font>
</p>
<p style="margin-top: 8px; margin-bottom: 0px;">
<font size="2"> Ziggler Warted</font>
</p>
</body>
</html>
从html上面提取body的方法
public static string GetHTMLBody(string htmlString)
{
string htmlBody = string.Empty;
if (!string.IsNullOrEmpty(htmlString) && htmlString.StartsWith("<html"))
{
htmlString = htmlString.Replace(" ", "");
XmlDocument doc = new XmlDocument();
doc.LoadXml(htmlString);
if (doc != null)
{
XmlNodeList xnList = doc.SelectNodes("/html/body");
if (xnList != null && xnList.Count > 0)
{
htmlBody = xnList[0].InnerXml;
}
}
}
else
{
htmlBody = htmlString;
}
return htmlBody;
}
在我的Model类中,我正如下面所做的那样
FormattedSignature = GetHTMLBody(MyHtmlSignature);
在cshtml中
<table>
<tr>
<td>
<div>
<input>
My Signature<br/>
<span>@Html.Raw(Model.FormattedSignature)/span>
</div>
</td>
</tr>
</table>
感谢所有帮助。我很感激。
答案 0 :(得分:0)
它看起来像a:focus(或者可能是:active?)选择器的浏览器默认样式。尝试使用其他浏览器进行比较和/或尝试将:focus {outline: none;}
添加到CSS中。