ASP.NET 将 & 转换为 &。我需要纯文本
ASP.NET Converting & to &. I need plain text
我四处寻找了一段时间的答案,但没有人找到答案,而且每个人都一直在说它应该如何工作。
我需要将 &(&符号)呈现为纯 javascript 代码。不是字符串。
if (@(Model.Month == null ? "now.getMonth() == tooltipItems[0].index" : "now.getMonth() == tooltipItems[0].index && now.getDay() == tooltipItems[0].index") && now.getFullYear() == $('#DistinctYears').val()) {
//
} else {
//
}
我需要这个部分:
"now.getMonth() == tooltipItems[0].index && now.getDay() == tooltipItems[0].index"
呈现为纯 javascript 代码,但在呈现时,& 符号会自动转换为 &&
用Html.Raw()包围整个三元表达式:
@Html.Raw(Model.Month == null ? "now.getMonth() == tooltipItems[0].index" : "now.getMonth() == " + (Model.Month - 1) + " && now.getDate() == (tooltipItems[0].index + 1)")
我四处寻找了一段时间的答案,但没有人找到答案,而且每个人都一直在说它应该如何工作。 我需要将 &(&符号)呈现为纯 javascript 代码。不是字符串。
if (@(Model.Month == null ? "now.getMonth() == tooltipItems[0].index" : "now.getMonth() == tooltipItems[0].index && now.getDay() == tooltipItems[0].index") && now.getFullYear() == $('#DistinctYears').val()) {
//
} else {
//
}
我需要这个部分:
"now.getMonth() == tooltipItems[0].index && now.getDay() == tooltipItems[0].index"
呈现为纯 javascript 代码,但在呈现时,& 符号会自动转换为 &&
用Html.Raw()包围整个三元表达式:
@Html.Raw(Model.Month == null ? "now.getMonth() == tooltipItems[0].index" : "now.getMonth() == " + (Model.Month - 1) + " && now.getDate() == (tooltipItems[0].index + 1)")