这是我的模特:
public class StockRequestModel
{
public int StockID { get; set; }
public int CategoryID { get; set; }
public int ItemID { get; set; }
public string TranCode { get; set; }
[Remote("CheckAvailableStocks", "Validation", AdditionalFields = "ItemID")]
public int ItemQuantity { get; set; }
public decimal ItemValue { get; set; }
public int PurchaseOrderID { get; set; }
public int MaterialRequesitionID { get; set; }
public int ReturnedByID { get; set; }
public string Remarks { get; set; }
public DateTime LastUpdateDate { get; set; }
}
我的网站上有多个页面使用此模型。请帮我看看如何在某些页面上启用/禁用此遥控器?
由于
答案 0 :(得分:3)
我会为每个视图创建单独的视图模型,并从类中继承继承
public class StockRequestBase
{
public int StockID { get; set; }
public int CategoryID { get; set; }
public int ItemID { get; set; }
public string TranCode { get; set; }
//other common properties
}
public class AddStockRequest : StockRequestBase
{
[Remote("CheckAvailableStocks", "Validation", AdditionalFields = "ItemID")]
public int ItemQuantity { get; set; }
}
public class AddStockRequestOptional : StockRequestBase
{
public int ItemQuantity { get; set; }
public string AnotherSpecificAttribute { set;get;}
}