This is just for curiosity
Why does this code work:
Html.TextBoxFor(x => x.Age, new { @Value = \"0\"})
and this doe
My guess is that the MVC code is hard coded to look for Value
because a MS engineer intended you to always use PascalCase property names, since that's their typical convention and PascalCase avoids conflicts with non-contextual keywords such as class
. Notice how PascalCase properties get rendered in the HTML as lowercase.
The reason is not about value
being a keyword, since it's a contextual keyword in C# and only has special meaning (and thus turns blue in the IDE) in property getters and setters. It has no special meaning in the anonymous type passed to TextBoxFor
.