【发布时间】:2015-10-28 14:11:14
【问题描述】:
这是我的方法
public ActionResult Index()
{
var viewModel = new Page();
var content = new EditableContent { SidebarRight = "sss", SidebarLeft = "fff" };
var content1 = new EditableContent { SidebarRight = "fff", SidebarLeft = "fggggg" };
var Contents= new List<EditableContent>{ content , content1 };
viewModel.Content = Contents;
return View(viewModel);
}
这是我的模型
public class EditableContent
{
public string SidebarLeft { get; set; }
public string SidebarRight { get; set; }
}
public class Page
{
public List<EditableContent> Content { get; set; }
}
这是我的看法Index
@model WebApplication6.Models.Page
@{
ViewBag.Title = "Index";
}
@using (Html.BeginForm())
{
@Html.EditorFor(page => page.Content, "Content")
<input type="submit" value="create" />
}
这是我的部分观点EditableContent
@model WebApplication6.Models.EditableContent
@Html.TextBoxFor(m => m.SidebarLeft)<br />
@Html.TextBoxFor(m => m.SidebarRight)
现在当我渲染索引页面时,它显示 sss , fff 并且它不调用模板代码?可能是什么问题
【问题讨论】:
标签: c# asp.net asp.net-mvc asp.net-mvc-4 razor