1、在视图中自定义一个控件格式: @Html.TextBox("txtemail", "", new { id = "txt_UserName", style = "width:280px;height:34px", @class = "input-easyui", @readonly = true })
2、在视图中绑定控件键盘触发事件:
$('#txt_UserName').combobox().next('span').find('input').bind("keyup", function (event) { var e = event || window.event; //火狐和其他浏览器取值 var keyCode = e.keyCode || e.which; if (keyCode == 13 && document.activeElement.value != null && document.activeElement.value != "") { $(document).ready(function () { $("#txtNumber").focus(); }); } });
3、JS给域文本框赋值方式:
控件定义: @Html.TextAreaFor(model => model.RecordedRemark, new { @class = "easyui-validatebox form-control", @readonly = true })
JS赋值:$("[name='RecordedRemark']").text(r.RecordedRemark);
4、JS给文本框输入焦点 $(document).ready(function () { $("#txt_expressno").focus(); });
5、Combobox下拉框动态去掉验证属性(required):$('#youPropertyId').combobox({ required: false });