我需要在项目中编辑一些属性,所以我想将输入输入到其他文本框中(它已经填充了信息)。
示例:
@Html.ValidationSummary()
@using (Html.BeginForm("Uprav", "Dnes", FormMethod.Post, new { @class =
"form-horizontal" }))
{
@Html.HiddenFor(x => x.Id)
<div class="form-group ">
<label class="col-sm-2 control-label warning">Registrační číslo:</label>
<div class="col-sm-2 ">
@Html.TextBoxFor(x => x.Reg_cislo, new { @class = "form-control" })
@Html.ValidationMessageFor(x => x.Reg_cislo)
</div>
</div>
从型号填写:
@model ClassLibrary1.Model.Kolobezka
有人可以帮我吗?
答案 0 :(得分:0)
尝试添加readonly
属性:
<div class="form-group ">
<label class="col-sm-2 control-label warning">Registrační číslo:</label>
<div class="col-sm-2 ">
@Html.TextBoxFor(x => x.Reg_cislo, new { @class = "form-control", @readonly = "true" })
@Html.ValidationMessageFor(x => x.Reg_cislo)
</div>
</div>
提交表单时,您显然必须忽略该字段服务器端(因为'readonly'不会阻止某人检查,更改字段中的值并提交该字段的数据)