I read ScottGu’s explanation on Strongly Typed Html Helpers and I understand that it gives me the ability to do better compile time checking of views. I was under the impression that I already had this when I used the model.PropertyName in the MVC1 Html.TextBox helper, but apparently that is not true. So, how does using a lambda expression do this better for me?
I read ScottGu’s explanation on Strongly Typed Html Helpers and I understand that it
Share
Consider the syntax of the existing HTML helper methods:
If you rename the
Quantityproperty on your object to “CurrentQuantity”, the generated<input>element will still havename="Quantity"specified, and model binding will break if you don’t remember to change that first parameter.By using a lambda expression to specify the name of the element, an incorrect or misspelled property name becomes a compilation error.