asp.net mvc - How Do I Set the Name and Value of an Editor Template Specific to the Model Being Edited? -


i'm trying use editor template standardise display of datepicker fields across multiple models in mvc4.

for example i'd standard display publishdate property on news model, , eventdate property on event model.

i have created datepicker.cshtml template , set uihint "datepicker" each of model properties. far good.

but how set name , value of editor template current model?

desired result

i'd use same editor template create inputs these:

<input name="eventdate" value="{currenteventdate}" class="datepicker"..... /> 

and

<input name="publishdate" value="{currentpublishdate}" class="datepicker".... /> 

use in datepicker.cshtml template, , place under views/shared/editortemplates:

@model system.datetime  @html.textbox("", model, new { @class = "datepicker" }) 

and, in main view:

@html.editorfor(model => model.eventdate) @html.editorfor(model => model.publishdate) 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -