开发者

MVC 3 - Editor template for List<> Model [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.

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 question

I 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜