1-后台生成html字符串的方法一般是:
this.ViewData.Add("CURRENCY_SYMBOLS", new HtmlString(JsonHelper.ConvertJsonToStr(jObjectCurrencySymbol)).Value);
2-前台显示:
window["Currency"] = { "Symbols" :ViewData["CURRENCY_SYMBOLS"], };
备注:有时候前台显示还是有编码字符,未按照html处理编码字符,我们可以将ViewData["CURRENCY_SYMBOLS"] 改为:@Html.Raw(ViewData["CURRENCY_SYMBOLS"])
@Html.Raw的功能也是让字符串按照Html编码方式显示处理(推荐):
window["Currency"] = { "Symbols" :@Html.Raw(ViewData["CURRENCY_SYMBOLS"]), };