我有三个Textbox将处于只读模式,例如
@Html.TextBoxFor(m => m.Whatever, new {@readonly = "readonly"})何时加载视图和一个编辑按钮。单击“编辑”按钮后,我希望它Textbox可以在同一文件中写入View。是否可以使用相同的View或者我必须创建另一个View没有@readonly = "readonly"属性的TextBox
3259 次
2 回答
3
您可以使用 javascript/jquery 删除readonly属性,例如
@Html.TextBoxFor(m => m.Whatever, new {@readonly = "readonly"})
<button id="edit" type="button">Edit</button>
$('#edit').click(function() {
$('#Whatever').prop('readonly', false);
});
于 2016-05-26T06:56:02.813 回答
0
下面是 TextBox和Edit按钮
@Html.TextBoxFor(m => m.Whatever, new {@readonly = "readonly"})
和
<button id="edit" type="button">Edit</button>
然后在 javascript
$('#edit').click(function() {
$('#Whatever').removeAttr("readonly");
});
这readonly将从TextBox.
于 2016-05-26T07:02:22.570 回答