【发布时间】:2016-10-24 19:08:40
【问题描述】:
我有这个模型
public partial class MtbWarehouse
{
public int Idhwarehouse { get; set; }
public string Namewh { get; set; }
}
我在这个视图模型中实现模型
public class WarehouseViewModel
{
public MtbWarehouse Warehouse { get; set; }
public string ListAction { get; set; } = "Index";
}
我在视图中使用 WarehouseViewModel
@model ViewModel.warehouseviewmodel
<input type="text" asp-for="Warehouse" class="form-control" placeholder="">
我如何使用asp-for 访问Namewh,因为这个 asp-for 的东西比使用更好
@Html.TextBoxFor()
【问题讨论】:
-
什么是
namewh?以前没听说过 -
namewh 是我在仓库视图模型中实现的模型中的属性
-
你想在哪里访问它?怎么样?
-
我想在视图仓库视图中访问它。过去使用 html.textbox 现在我不知道。
-
你试过
asp-for="Warehouse.Namewh"吗?看起来你的@model 与你的类名不匹配,但我假设有很多工作。
标签: asp.net asp.net-mvc asp.net-core viewmodel tag-helpers