我有一个基于字段值的视图,必须显示自定义标签。
视图模型:
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 €)