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 259 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 1932 posts 6722 karma points MVP 2x c-trib
    Aug 07, 2022 @ 06:26
    Huw Reddick
    0

    try

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

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies