c# - HTML.textBoxFor(x=>x.Price, disabled = true) 不会将值发布到 Controller 发布操作!

标签 c# html asp.net-mvc-3

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/

相关文章:

c# - Linq 到 Nhibernate : HqlTreeBuilder with Elements how to use?

html - 如何根据列表中的项目数量在 div 标签内添加新的 html 元素?

javascript - 如何在 CSS 中将颜色设置为用户的链接颜色?

html - 让 HTML 识别\n 和\t

asp.net - MVC4 上 _layout.cshtml 的@model?

c# - 在 EF 查询中格式化 DateTime

c# - 为什么调用基类方法而不是派生类方法?

c# - 在 C# 中使用计时器实现循环

javascript - 根据复选框更改文本框值

javascript - 如何实现代码按钮来格式化文本区域中的文本?