Asp .net MVC 3 应用程序... 这是 View :
Grupa: <%= Html.DropDownListFor(x => x.Grupa, Model.ListaGrupe) %>
Produsul: <%= Html.DropDownListFor(x => x.Produs, Model.ListaProduse) %>
Cantitate: <%=Html.TextBoxFor(x => x.Cantitate, new { style = "width: 100px;" })%>
Pret: <%=Html.TextBoxFor(x => x.Pret, new { style = "width: 100px;", disabled = true})%>
TVA: <%= Html.TextBoxFor(x => x.TVA, new { style = "width: 100px;", disabled = true })%>
Valoare: <%= Html.TextBoxFor(x => x.NoTVA, new { style = "width: 120px;", disabled = true})%>
Valoare cu TVA: <%=Html.TextBoxFor(x => x.Total, new { style = "width: 120px;", disabled = true})%>
我正在使用一些 JQuery 来根据 Grupa、Produs 和 Cantitate 中的值更改 Pret、TVA、NoTVA 和 Total,因此我不希望用户修改其中的值。 可能不应该使用 disabled = true。那么我怎样才能让用户不能修改字段,而是要发布到 Controller 操作的值?
最佳答案
您也可以将它们设置为只读而不是禁用它们。另一方面,我认为@Chris 解决方案更好,这样您修改后的数据将被回发。
关于c# - HTML.textBoxFor(x=>x.Price, disabled = true) 不会将值发布到 Controller 发布操作!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6395476/