【发布时间】:2019-09-18 04:05:15
【问题描述】:
我正在使用来自我的控制器的数据设置 Razor 变量,如下所示:
@{
var filterData = ((ShipmentController)this.ViewContext.Controller).GetNoCmrs(new List<int>() { 1 });
}
我想根据用户选择的选项(在选择范围内)更改此数据。
<script>
var x;
function loadShipmentsByCondition() {
x = document.getElementById("conditionSelect").value;
if (x === "CMR not received") {
@filterData = @newData;
} else if(x === "Not invoiced") {
console.log("INVOICE");
@filterData = @otherData;
}
}
</script>
这可能吗?或者如果没有,我怎样才能有效地做到这一点? 我使用 MVC ASP.NET 和 vue js 作为前端。
谢谢
【问题讨论】:
-
不能在客户端设置
@filterData。 -
您可以随时向您的控制器/处理程序发回一个发布请求以设置此值
标签: c# asp.net vue.js razor model-view-controller