如果大学录取=“ C”或“ U”,我需要隐藏“ Firm” div组。大学录取还可以是“ R”(已拒绝)和“ P”(待定)。
'
<div class="form-group">
@Html.LabelFor(model => model.UniversityOffer, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UniversityOffer, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.UniversityOffer, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Firm, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
<div class="checkbox">
@Html.EditorFor(model => model.Firm)
@Html.ValidationMessageFor(model => model.Firm, "", new { @class = "text-danger" })
</div>
</div>
</div>
'
答案 0 :(得分:0)
尝试如下:
@{
if(!(Model.UniversityOffer == "C" || Model.UniversityOffer == "U"))
{
<div class="form-group">
@Html.LabelFor(model => model.Firm, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
<div class="checkbox">
@Html.EditorFor(model => model.Firm)
@Html.ValidationMessageFor(model => model.Firm, "", new { @class = "text-danger" })
</div>
</div>
</div>
}
}