MVC 3 - Editor template for List<> Model [closed]
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this questionI am building my first Razor app and really loving it. I am trying to get the low-down on how to create an editor template that renders out an editable list of items without a foreach loop. Is this possible?
Here are the basics of what I am trying to achieve:
In my view (Views/Image/Homepage.cshtml) I have:
@model List<MyNameSpace.Image>
@{
ViewBag.Title = "Homepage Images";
}
@*????*@
@Html.EditorFor(Model => Model)
And in my editor template (Views/Image/EditorTemplates/Image.cshtml??) I have:
@model MyNameSpace.Image
<div>@Html.TextBoxFor(Model => Model.Title)</div>
<div>@Html.TextBoxFor(Model => Model.LongDes开发者_JAVA百科cription)</div>
LOL this is embarrassing but worthy of mentioning, the code above works fine, I created a test list in the controller but forgot to pass it to the view :-D
精彩评论