如何有条件地禁用基于Model Id ASP.NET Mvc 4的@HtmlEditorFor

时间:2016-12-14 15:21:52

标签: c# asp.net-mvc-4 razor html-helper

如果Model.Promotion.PromotionID为10,我想有条件地禁用此按钮或隐藏它。不确定如何操作。 我试图找到解决方案,但努力解决它。

非常感谢帮助谢谢

 @using (Html.BeginForm("Edit", "Promotion", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    @Html.HiddenFor(model => model.Promotion.PromotionID)

    @Html.HiddenFor(model => model.Promotion.Active)


    <fieldset class="fieldset">
        <legend class="legend">Edit Promotion</legend>

        <div>

        <div class="editor-field" title="The name of the Promotion"  @((Model.Promotion.PromotionID == 209) ? "disabled" : "")>
                    @Html.EditorFor(model => model.Promotion.PromotionTitle )
                    @Html.ValidationMessageFor(model => model.Promotion.PromotionTitle)
                </div>

                </div>

0 个答案:

没有答案