Here is my method

  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);
    }

Here is my model

   public class EditableContent
{
    public string SidebarLeft { get; set; }
    public string SidebarRight { get; set; }
}

public class Page
{
    public List<EditableContent> Content { get; set; }
}

here is my view Index

@model WebApplication6.Models.Page
@{
    ViewBag.Title = "Index";
}


@using (Html.BeginForm())
{   
    @Html.EditorFor(page => page.Content, "Content")  
    <input type="submit" value="create" />
}

Here is my partial view EditableContent

@model WebApplication6.Models.EditableContent

@Html.TextBoxFor(m => m.SidebarLeft)<br />
@Html.TextBoxFor(m => m.SidebarRight)

now when i render the Index page it displayed sss , fff and it doesn't call the template code? what might be the issue

Related posts

Recent Viewed