I thought Html.HiddenFor
could use Templates like Html.DisplayFor
or Html.EditorFor
. Unfortunately the method doesn't accept a TemplateName
like the others.
I know, the workaround would be to use a DisplayFor/EditorFor Template which has HiddenFors. But I would like to find out how to extend the Html.HiddenFor
method. Anyone?
Regards
Seems like you are mislead by wrong analogy. HiddenFor
corresponds exactly to the <input type="hidden"/>
tag. Just like TextBoxFor
, CheckBoxFor
etc. These methods are not designed to use templates. DisplayFor
/EditorFor
on the other side are specially created to be used with templates defined in the project. Thus what you are asking for is not possible out-of-the-box.
However you can always define your own overload for HiddenFor
with whatever set of parameters and whatever logic you might require.