Copied to clipboard

Flag this post as spam?

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


  • Tom Bruce 122 posts 506 karma points
    Jul 26, 2017 @ 13:10
    Tom Bruce
    0

    inherits' keyword is not allowed when a 'model' keyword is used.

    Hi, how do I include the following keywords within my view page,

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @model Models.Employees

    Error Parser Error Message: The 'inherits' keyword is not allowed when a 'model' keyword is used.

    code below;

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @model Models.Employees

    @{ Layout = "WebBase.cshtml"; }

    @{ Html.RenderAction("RenderTitleControls", "SiteLayout");} @CurrentPage.GetGridHtml("contentGrid", "bootstrap3")

    @{ Html.RenderAction("Create", "Applicants"); }

  • Tim Watts 90 posts 395 karma points
    Jul 26, 2017 @ 13:16
    Tim Watts
    0

    Hi Tom,

    Use this:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<Models.Employees>
    

    Regards,

    Tim

  • Tom Bruce 122 posts 506 karma points
    Jul 26, 2017 @ 13:27
    Tom Bruce
    0

    Receiving error;

    Compiler Error Message: CS0311: The type Models.Employees.' cannot be used as type parameter 'TContent' in the generic type or method 'Umbraco.Web.Mvc.UmbracoTemplatePage

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Jul 26, 2017 @ 14:03
    Alex Skrypnyk
    100

    Hi Tom

    Try this:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Employees>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    
  • Tom Bruce 122 posts 506 karma points
    Jul 26, 2017 @ 14:36
    Tom Bruce
    0

    Hi Alex, receiving error

    Name Employees does not exist in the namespace Umbraco.Web.PublishedContentModels(are you missing an assembly

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Jul 26, 2017 @ 15:37
    Alex Skrypnyk
    0

    Tom, what is Employees? Is it doctype or custom model?

  • Tom Bruce 122 posts 506 karma points
    Jul 26, 2017 @ 16:04
    Tom Bruce
    0

    Employee is a table from the Entity. I have used Entity Framework to model the data from the database.

    I think I need to include the ref @model.Models.Employees to access the data and @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    I'm just trying to access the data from the View like

     <div class="form-group">
            @Html.LabelFor(model => model.Forename, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Forename, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Forename, "", new { @class = "text-danger" })
            </div>
        </div>
    
  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Jul 26, 2017 @ 20:37
    Alex Skrypnyk
    1

    Yes, definitely you have to include @model.Models.Employees

Please Sign in or register to post replies

Write your reply to:

Draft