我在Razor视图中有一个DropDownList和一个TextArea。我希望TextArea仅在下拉列表中的特定值被选中时才可见。有什么解决方案可以做到这一点?这是我到目前为止所尝试的,但它不是很正确,因为它假定设置了安全类型的值。在同一视图中访问MVC下拉选定值
<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的。 –