Model Binding With Disabled Textbox

前端 未结 7 2064
余生分开走
余生分开走 2020-12-09 07:23

I have a textbox that I am defining as

<%= Html.TextBox(\"Username\", Model.Form.Username, 
        new { @class = \"textbox\", @disabled = \"disabled\" }         


        
7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 07:53

    If you want the value to be sent back, but not be editable, consider placing it in a hidden field. Obviously, don't do this for anything that requires a degree of security, since a user can tamper with it.

提交回复
热议问题