Copied to clipboard

Flag this post as spam?

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


  • David 2 posts 22 karma points
    Apr 14, 2013 @ 02:07
    David
    0

    UmbracoTemplatePage with custom model

    Hi! Is it possible to have a custom model with a UmbracoTemplatePage like that :

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<Koit.Models.ContactModel()> ?

    I know I can use a partial view to get my ContactModel but I also need every Umbraco.Field("").

    Thank you for your help!!!

    Dave

     

  • Charles Afford 1163 posts 1709 karma points
    Apr 14, 2013 @ 13:53
    Charles Afford
    0

    Hi, are you having trouble passing to a partial view?.  What i did was created a public property NodeId {get;set;} in my model.  In my view i instanced my model and set NodeId to the context nodeId (Node.GetCurrent().Id) and then passed this instance into the partial.  In the partial i can then say

    @model Koit.Models.ContactModel() // @Model to get these properties

    DynamicNode ctxNode = new DynamicNode(@model.NodeId)

    ctxNode....

    Hope this makes sense.  Charlie :)

  • Brett Spencer 88 posts 258 karma points
    Jul 01, 2015 @ 14:22
    Brett Spencer
    1

    I came across this issue in 7.1.8 +...

    The best answer to this question is located here in documentation.

    Instead of using

    > Umbraco.Web.Mvc.UmbracoTemplatePage
    

    Which will not recognize a custom model, use...

    > Umbraco.Web.Mvc.UmbracoViewPage<T>
    

    Where T is your custom model. This helped me greatly when creating forms in multi-languages. I used the Dictionary and a custom model to send the form data to an external API in my controller.

  • 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