Copied to clipboard

Flag this post as spam?

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


  • slawekg 9 posts 29 karma points
    Oct 05, 2009 @ 13:50
    slawekg
    0

    Pass item to c# code

    Hello All!

    I am having such structure:

    1. language

                 2.page

     

    On 1 level I have defined some item, for example item_language, with value 'en'.

    On level 2, in template, I'm trying do to a redirect using this value.

    For example, I've placed  a asp:button, attached click event and I'm trying to get the value with the code below:

    umbraco.presentation.nodeFactory.Node nd = umbraco.presentation.nodeFactory.Node.GetCurrent();
    umbraco.presentation.nodeFactory.Property pt = nd.GetProperty("item_language");
     string val = string.Empty;
     if (pt != null)
                    val = pt.Value;
     if(!string.IsNullOrEmpty(val))
      Response.Redirect(val);

    That of course doesn't work. It would work if I would be fetching item from the 2 level.

    Does anyone knows how to do what I'm after here?

  • Mikael Mørup 297 posts 326 karma points
    Oct 05, 2009 @ 14:20
    Mikael Mørup
    0

    try

    nd.parent.GetProperty("item_language");

     

    Mikael

  • slawekg 9 posts 29 karma points
    Oct 05, 2009 @ 14:48
    slawekg
    0

    Thanks for good idea - I'll implement this recursively up to the very top. Should work for no matter how deep node level.

  • Mikael Mørup 297 posts 326 karma points
    Oct 05, 2009 @ 16:00
    Mikael Mørup
    0

    I think there is an API function for getting a property recursively, i just can't find it right now.

    Mikael

Please Sign in or register to post replies

Write your reply to:

Draft