Razor 视图,如何根据模型 ID 禁用 @htmlEdittorFor 或使其准备就绪

Razor View, How to disable @htmlEdittorFor or Make it ready depending on Model Id

我想有条件地禁用此按钮,或将其设置为只读,以便用户只能看到显示在框中或文本中的数据,但无法进行任何编辑,我已尝试了很多步骤来解决这个问题,但是如果您查看下面的代码,似乎没有任何效果。

任何人都可以为我提供建议或为此事提出解决方案。 提前谢谢你。

enter image description here

<div class="inline-block-side">
    @if (Model.Promotion.PromotionID == 209)
    {
        @Html.DisplayFor(model => model.Promotion.PromotionTitle) 
    }
    else
    {
        <div class="editor-label">
            @Html.LabelFor(model => model.Promotion.PromotionTitle)
        </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 class="editor-label">
            @Html.LabelFor(model => model.Promotion.ArtworkDate)
        </div>
        <div class="editor-field" title="The date the Artwork is to be recieved by">
            @Html.TextBoxFor(model => model.Promotion.ArtworkDate, "{0:dd/MMM/yyyy}", new { @id = "ArtworkDate", @class = "date" })
            @Html.ValidationMessageFor(model => model.Promotion.ArtworkDate)  
        </div>

您可以使用@Html.DisplayFor来解决您的问题,或者您可以用户jquery启用、禁用属性使文本框只读