Html.Encode和包含html代码段的字符串
|
我正在尝试在某些文本中突出显示搜索结果。我写了一个扩展方法:
public static string Highlight(this HtmlHelper html, string input, string searchPhrase)
{
Regex.Replace(input,
\"\\\\b\" + searchPhrase + \"\\\\b\",
\"<strong>\" + searchPhrase + \"</strong>\",
RegexOptions.IgnoreCase);
}
但是很明显,当它是Html.View编码时,html标记只是作为文本的一部分呈现。
有更好的方法吗?或者,如果我的想法还可以,我如何使它起作用?
没有找到相关结果
已邀请:
1 个回复
悸翠疮武昏
并在视图中: