【发布时间】:2014-05-24 00:34:21
【问题描述】:
我已经勾选了我想要的复选框,如果 show=true(show = Boolean type)启用文件上传,所以默认情况下该复选框未选中并且文件上传被禁用,我该怎么做? 当您单击启用/禁用不起作用时,我尝试使用以下无法正常工作的代码。
$(function () {
$("#show").change(function () {
$("#fileUpload").toggle(this.checked).prop("disabled", false);
});
});
$("#fileUpload").toggle(this.checked).prop("disabled", true);
<div class="form-group">
@Html.LabelFor(model => model.show, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.show)
@Html.ValidationMessageFor(model => model.show)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.File, new { @class = "control-label col-md-2" })
<div class="col-md-10">
<input type="file" id="fileUpload"/>
</div>
</div>
【问题讨论】:
标签: javascript jquery asp.net asp.net-mvc asp.net-mvc-3