Lor*_*ion 1 c# asp.net-mvc razor
我有一个禁用的输入字段,显示模型中的数据。
\n\n<div class="form-group">\n @Html.LabelFor(model => model.first_name, "F\xc3\xb6rnamn", new\n {\n @for = "inputFirstname",\n @class = "col-lg-3 control-label"\n })\n <div class="col-lg-9">\n @Html.TextBoxFor(model => model.first_name, new\n {\n @type = "text",\n @class = "form-control",\n @id = "inputFirstname",\n text = Html.DisplayNameFor(model => model.first_name),\n disabled="disabled"\n })\n </div>\n </div>\nRun Code Online (Sandbox Code Playgroud)\n\n我可以将此数据提交给 controlelr 方法:
\n\n[http邮报]
\n\npublic ActionResult Index(RegistrationModel RegistrationModelViewModel)\n{}\nRun Code Online (Sandbox Code Playgroud)\n\n当我添加disabled="disabled"first_name数据为空时,如果我删除它,我会得到正确的数据。
我究竟做错了什么?
\n小智 6
如果您还想显示数据,您可能需要使用只读属性:
@Html.TextBoxFor(model => model.first_name, new
{
@readonly = "readonly"
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3403 次 |
| 最近记录: |