Display a value in a disabled textbox using TextBoxFor
I'm tryin开发者_开发问答g to display a disabled textbox with the value 'FL' in it. Somehow the textbox does not have any value when it is displayed, but it is disabled. How do you display a value in a disabled textbox?
<%= Html.TextBoxFor(model => model.State, new { value="FL", disabled="disabled" }) %>
I think the code:
Html.TextBoxFor(model => model.State, new { disabled="disabled" });
is the code you need.
In the model
, set the State = 'FL'
& it should work correctly...
HTH.
You may write like this:
<%= Html.TextBoxFor(model => model.State, new { @Value="FL", disabled="disabled" }) %>
"@" need, because value is a reserved world
精彩评论