I want to write a HtmlHelper extension method similar to HiddenFor. The difference is that I want to control what goes into the value attribute as well as tack on an extra attribute. I figured I could just look at the source code for MVC, being as how its open source and all. But, unless I am blind, it appears that the strongly typed helper methods like HiddenFor, TextBoxFor, etc, are not included in the source code.
The method signature uses Expression> expression.
Given the expression how can I get the same value of the name attribute that HiddenFor would?
Everything is included in the source code, just download it and look at
InputExtensions.cs.So to get the name:
ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData)