【发布时间】:2016-07-25 03:47:18
【问题描述】:
我在 Razor 视图中有一个 DropDownList 和一个 TextArea。我希望只有在选择了下拉列表中的特定值时才能看到 TextArea。有什么解决方案可以做到这一点?到目前为止,这是我尝试过的,但它并不完全正确,因为它假定设置了 Security 类型的值。
<tr>
<td style="width: 200px; height: 30px">
@Html.LabelFor(model => model.SecurityTypeId)
</td>
<td style="width: 400px; height: 30px">
@Html.DropDownListFor(model => model.SecurityTypeId, Model.SecurityTypes, dropdownHtmlAttrs)
</td>
<td> </td>
</tr>
<tr>
@if (Model.SecurityTypeId == (int)(SecurityType.Other))
{
<td style="width: 200px; height: 30px">
@Html.LabelFor(model => model.Details)
</td>
<td style="width: 400px; height: 30px">
@Html.TextAreaFor(model => model.Details, new { Style = "width:240px" })
</td>
<td> </td>
}
</tr>
【问题讨论】:
-
如果你想响应客户端事件,你需要javascript/jquery。
标签: asp.net-mvc razor