BootstrapTable+KnockoutJS自定义T4模板快速生成增删改(4)

@model TestKO.Models.User <form> @Html.HiddenFor(model => model.Id) <div> <div> @Html.LabelFor(model => model.Name, "Name", new { @class = "control-label col-xs-2" }) <div> @Html.TextBoxFor(model => model.Name, new { @class = "form-control", data_bind = "value:editModel.Name" }) </div> </div> <div> @Html.LabelFor(model => model.FullName, "FullName", new { @class = "control-label col-xs-2" }) <div> @Html.TextBoxFor(model => model.FullName, new { @class = "form-control", data_bind = "value:editModel.FullName" }) </div> </div> <div> @Html.LabelFor(model => model.Age, "Age", new { @class = "control-label col-xs-2" }) <div> @Html.TextBoxFor(model => model.Age, new { @class = "form-control", data_bind = "value:editModel.Age" }) </div> </div> <div> @Html.LabelFor(model => model.Des, "Des", new { @class = "control-label col-xs-2" }) <div> @Html.TextBoxFor(model => model.Des, new { @class = "form-control", data_bind = "value:editModel.Des" }) </div> </div> <div> @Html.LabelFor(model => model.Createtime, "Createtime", new { @class = "control-label col-xs-2" }) <div> @Html.TextBoxFor(model => model.Createtime, new { @class = "form-control", data_bind = "value:editModel.Createtime" }) </div> </div> <div> @Html.LabelFor(model => model.strCreatetime, "strCreatetime", new { @class = "control-label col-xs-2" }) <div> @Html.TextBoxFor(model => model.strCreatetime, new { @class = "form-control", data_bind = "value:editModel.strCreatetime" }) </div> </div> </div> <div> <button type="button" data-dismiss="modal"><span aria-hidden="true"></span>关闭</button> <button type="submit"><span aria-hidden="true"></span>保存</button> </div> </form> <script src="https://www.jb51.net/~/Scripts/extensions/knockout.edit.js"></script> <script type="text/javascript"> $(function () { var model = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model)); var viewModel = { formId: "formEdit", editModel : model, urls : { submit : model.id == 0 ? "/User/Add" : "/User/Update" }, validator:{ fields: { Name: { validators: { notEmpty: { message: '名称不能为空!' } } } } } }; ko.bindingEditViewModel(viewModel); }); </script> Edit.cshtml

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzxxgd.html