Copied to clipboard

Flag this post as spam?

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


  • Barry Fogarty 493 posts 1129 karma points
    Apr 10, 2013 @ 19:07
    Barry Fogarty
    0

    MVC: Using the UmbracoHelper dictionary in a Partial View with a custom model

    I have a contact form child action called as follows:

    @Html.Action("RenderContactForm", "ContactFormSurface")

    The action in the controller returns a partial view with a custom model passed in to it as follows:

    return PartialView("ContactForm", new ContactFormModel());

    Do I need to pass something in to this view so I can access the UmbracoHelper methods?  I cannot inherit UmbracoTemplatePage from this view as it uses a custom model.

  • Charles Afford 1163 posts 1709 karma points
    Apr 10, 2013 @ 22:31
    Charles Afford
    0

    Hi i had the same problem.  I created a new property in my model NodeId.

    I instanced my model in the view assigned the property value and then passed the model in to the partial.  

    In the partial i could then instance a new Node passing in my NodeId.  Hope this helps.  Charlie :)

  • Charles Afford 1163 posts 1709 karma points
    Apr 10, 2013 @ 22:33
    Charles Afford
    102

    You can also do:  I think its 

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<YourCustomModel>

    its explained half way down on this page :)

    http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx

  • Barry Fogarty 493 posts 1129 karma points
    Apr 12, 2013 @ 10:52
    Barry Fogarty
    0

    #H5YR Charlie.  I should have clarified, I wanted to use a dictionary value with Umbraco.GetDictionaryValue("") so the second method was what I needed.

     

Please Sign in or register to post replies

Write your reply to:

Draft