Model Binding With Disabled Textbox
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?
<div class="editor-label">
@Html.LabelFor(model => model.FileName)
</div>
<div class="editor-field-greyed-out">
@Html.TextBoxFor(model => model.FileName, new { @readonly = true })
@Html.ValidationMessageFor(model => model.FileName)
</div>
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.
I believe a form field that is disabled does not submit anything. If you have a form and disable the foo field in that form, when you post the post will not have the value for the foo field. This is simply the nature of disabling a field in HTML and is not a MVC issue.