我想将文本框设置为只读,如果它在 MVC 中具有价值。
所以我写
<tr>
@if (model.first_name != "" ) {
<td >
@Html.LabelFor(model => model.first_name):
</td>
<td >
@Html.TextBoxFor(model => model.first_name)
<span class="required">*</span>
@Html.ValidationMessageFor(model => model.first_name)
</td>
@ else
<td >
@Html.LabelFor(model => model.first_name):
</td>
<td >
@Html.EditorFor(model => model.first_name)
<span class="required">*</span>
@Html.ValidationMessageFor(model => model.first_name)
</td>
@}
<td >
@Html.LabelFor(model => model.first_name):
</td>
<td >
@Html.EditorFor(model => model.first_name)
<span class="required">*</span>
@Html.ValidationMessageFor(model => model.first_name)
</td>
</tr>
但是它不起作用..如何解决它?我该怎么做??