Model Binding With Disabled Textbox

前端 未结 7 2062
余生分开走
余生分开走 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:55

    use readonly - will disable input but you'll still have it in the binding. You could apply a style on the div to make it looked greyed out maybe?

    @Html.LabelFor(model => model.FileName)
    @Html.TextBoxFor(model => model.FileName, new { @readonly = true }) @Html.ValidationMessageFor(model => model.FileName)

提交回复
热议问题