我有一个基于字段值的视图,必须显示自定义标签。基于字段值的自定义显示注释
视图模型:
public class CreateAdViewModel
{
public int Operation_Id { get; set; }
[Display(ResourceType = typeof(HeelpResources), Name = "AdViewModel_Price_Label")]
public decimal Price { get; set; }
}
查看:
<div id="price">
@Html.DisplayNameFor(m => m.Price)
@Html.TextBoxFor(m => m.Price) €
@Html.ValidationMessageFor(m => m.Price)
</div>
我想显示:
"Price: " if Operation_Id = 1 (For the Sale of a Car)
而且
"Price Up To: " if Operation_Id = 2 (For someone looking for a car until value XX €)
是字段值已知的,在页面加载不可变? – mattytommo
嗨,它是在向导的第一步中定义的,并且标签必须在向导的第三步中设置,所以是的,当我们进入第三步时,Operation_Id不会改变。希望我回答你的问题 – Patrick