Using a edit template without using Html.EditorFor()
Posted
by Mark Nijhof
on Stack Overflow
See other posts from Stack Overflow
or by Mark Nijhof
Published on 2010-03-30T10:56:15Z
Indexed on
2010/03/30
17:33 UTC
Read the original article
Hit count: 400
asp.net-mvc
I have a date time picker combination in a edit template that can be used like Html.EditorFor(x => x.ETA) but now I want to use the same template somewhere where I don't have a model that contains a DateTime property. So I tried Html.Editor("DateWithTime", "Arrival") which uses the correct template, but doesn't assign a value to ViewData.ModelMetadata.PropertyName which is something that my template relies on. It sets the id of the textbox which is obviously important.
Is there a way to render the template and assign a id value to the ViewData.ModelMetadata.PropertyName so I can re-use the logic in the template instead of having to copy it?
© Stack Overflow or respective owner