In Razor I know that if you write
@Html.HiddenFor(x => x.PropertyX.PropertyY)
it will generate HTML like:
<input type="hidden" name="PropertyX.PropertyY" value="...">
And (especially) if this was in an Editor Template it might generate this HTML:
<input type="hidden" name="ParentProperty[12].PropertyX.PropertyY" value="...">
How do I get a name for an arbitrary property? I’m assuming there must be some way to do this using MVC infrastructure (perhaps some method or class?)
You could write a custom helper for that:
and then: