Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Linx 98 posts 258 karma points
    Aug 06, 2022 @ 11:34
    Linx
    0

    Custom model in Umbraco 8

    • Document Type: HelloWorld
    • Controller name: HelloWorldController
    • Template: HelloWorld

    Template code:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.CustomModel>
    @using ContentModels = Umbraco.Web.PublishedModels;
    
    @Html.LabelFor(m=> m.XXXX)
    

    I cant get access to any property under 'm'

    Controller code

     public class HelloWorldController :  RenderMvcController
          {
    
            public ActionResult Index(ContentModel model)
            {
                CustomModel cm = new CustomModel();
                cm.Id = 1;
                cm.Name = "Test";
                return CurrentTemplate(model.Content);
            }
    

    This throws a cast error when my template is rendered.

    Why is this?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 07, 2022 @ 06:26
    Huw Reddick
    0

    try

    @Html.LabelFor(m=> Model.XXXX)

Please Sign in or register to post replies

Write your reply to:

Draft