Copied to clipboard

Flag this post as spam?

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


  • hetaurhet 245 posts 267 karma points
    Feb 19, 2012 @ 15:47
    hetaurhet
    0

    Parent property in template

    hello

    I want to access Parent's heading property in template which is applied to its children. How can I write Razor for that in template? Is that possible?

  • Douglas Ludlow 210 posts 366 karma points
    Feb 19, 2012 @ 16:20
    Douglas Ludlow
    0

    Yes, of course! You can access the current node's parent by using DynamicNode's Parent property. If the heading property's alias is heading, then something like:

    <umbraco:Macro runat="server" language="cshtml">
        string heading = Model.Parent.heading;
        <h1>@heading</h1>
    </umbraco:Macro>

    ...should get the job done.

  • hetaurhet 245 posts 267 karma points
    Feb 25, 2012 @ 05:16
    hetaurhet
    0

    thank you..

    but in my template it works as below and not by declaring string.

    <h1>@Model.Parent.heading;</h1>
Please Sign in or register to post replies

Write your reply to:

Draft