I want to do something like this so I can create a modal dialog that I'll invoke late with jQuery
<div class="modal" id="modalName" style="display: none;">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Edit Contacts</h3>
</div>
@using (Html.BeginForm("Index", "Home", FormMethod.Post, new Dictionary<string, object> { { "class", "form-horizontal" } }))
{
<div class="modal-body">
@Html.EditorFor(model => new ViewModel(), "ViewModelTemplateName")
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Close</a>
<button type="submit" class="btn btn-primary">
Submit</button>
</div>
}
</div>
On this line
@Html.EditorFor(model => new ViewModel(), "ViewModelTemplateName")
I get the error
Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.
I don't understand why it would care where or what the instance is (as long as its the right type)
@Html.Partial("~/Views/Shared/EditorTemplates/ViewModel.cshtml", new ViewModel()) does the trick, but I have to declare the full path the the template...this sucks a bit.
so is there a better way to do it?