将我的 MVC3 (aspx) 项目迁移到 MVC5 (razor),我使用:
<% if ((bool)this.ViewData["ReadOnly"] != true)
{ %>
document.getElementById("NextAction").value = nextAction;
document.getElementById("VisitForm").submit();
<% } else { %>
window.location = nextAction;
<% } %>
我将其修改为:
@if ((bool)this.ViewData["ReadOnly"] != true)
{
document.getElementById("NextAction").value = nextAction;
document.getElementById("VisitForm").submit();
} else {
window.location = nextAction;
}
无法解析文档或窗口?
最佳答案
您缺少脚本标签。就像这样:
@if ((bool)this.ViewData["ReadOnly"] != true)
{
<script>
document.getElementById("NextAction").value = nextAction;
document.getElementById("VisitForm").submit();
</script>
}
else
{
<script>
window.location = nextAction;
</script>
}
关于javascript - Razor View MVC 5 JavaScript - 解析 document.getElementById,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26720314/