我有一個基於字段值的視圖,必須顯示自定義標籤。基於字段值的自定義顯示註釋
視圖模型:
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