MVC and Entity Framework Html.DisplayNameFor with Composite ViewModel

后端 未结 2 481
一生所求
一生所求 2021-01-01 16:35

I’m fairly comfortable with MVVM using WPF/Silverlight but this is my first attempt at an MVC Web Application…just an fyi for my background.

I’ve created a controlle

2条回答
  •  死守一世寂寞
    2021-01-01 17:06

    I'll take a stab with my newly learned MVVM ASP.NET MVC experience.

    Instead of calling @Html.DisplayNameFor(model => model.WebPageTitle), try using @Html.DisplayFor(model => model.WebPageTitle). You appear to be setting the WebPageTitle value in your IndexWithViewModel controller which should show up in your view.

    Look into shared templates for ASP.NET MVC. You can set up custom templates or partials for DisplayFor/EditorFor helpers at /Views/Shared/EditorTemplates/Site.cshtml and /Views/Shared/DisplayTemplates/Site.cshtml. ASP.NET MVC will automatically pick up on those templates when rendering your Site object with DisplayFor and EditorFor.

    Good luck!

提交回复
热议问题