如何逃脱html.actionLink&所述a取代;&下; / A&GT;在标签的String.Format [英] How to escape html.actionLink <a></a> tags in string.format
本文介绍了如何逃脱html.actionLink&所述a取代;&下; / A&GT;在标签的String.Format的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为了让我们使用 {0}
作为占位符翻译文本中的一个URL。
To make an URL within a translatable text we use {0}
as placeholder.
所以我们做的:
@string.Format(@translationHelper.GetTranslation("label-ClickToContinue"),
@Html.ActionLink(
@translationHelper.GetTranslation("text-here"),
"Login",
new { Model.UserName, Model.UniqueId }
)
)
翻译键:
label-ClickToContinue = "Click {0} to continue"
text-here = "here"
但这种打印逃串入来源:&放大器; LT;一href=\"/Login/Login?UserName=alberttest3&amp;UniqueId=f3647fed-bab4-4575-bb5f-98ed27edff43\">label-RequestNewOfficeWizard</a>$c$c>
如何确保它会不显示HTML标记,但网址是什么?
How to make sure that it'll not show the html-tag, but the URL?
推荐答案
很容易的只是把从的String.Format输出()
A <$ C内$ C> Html.Raw() 是这样的:
It easy just put the output from string.Format()
inside a Html.Raw()
like this:
@Html.Raw(string.Format(@translationHelper.GetTranslation("label-ClickToContinue"),
@Html.ActionLink(
@translationHelper.GetTranslation("text-here"),
"Login",
new { Model.UserName, Model.UniqueId }
)
))
翻译键:
label-ClickToContinue = "Click {0} to continue"
text-here = "here"
这篇关于如何逃脱html.actionLink&所述a取代;&下; / A&GT;在标签的String.Format的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文