Copied to clipboard

Flag this post as spam?

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


  • Giovanni Sidoel 94 posts 233 karma points
    May 24, 2012 @ 17:07
    Giovanni Sidoel
    0

    Getting values from umbraco.library.GetCurrentMember() in .net usercontrol

    Guys,

    I'm trying to access some data in my .net usercontrol. Specifically I want to know the node id of the currently logged on member. Any idea how I should do this?

    Here's some code I have right now:

    dynamic xmlv = new DynamicXml(umbraco.library.GetCurrentMember());
            foreach (var property in xmlv)
    {
                foreach (var item in property)
                {
                        Response.Write(item.InnerText);
                        Response.Write("<br/>");
                }
                    Response.Write(property.naam);
                    Response.Write("<br/>???");
    }

     

    This returns absolutely nothing.

    P.S: I'm more of an XSLT guy so please be really specific.

     

     

     

  • Giovanni Sidoel 94 posts 233 karma points
    May 24, 2012 @ 20:40
    Giovanni Sidoel
    0

    Nevermind,

    After hours of going crazy I found a way to do it.

    Let's sat you have a member xml that looks like this:


    gsidoel
    kernkampweg 4-6
    Paramaribo
     

     

    And you wanted to read the value of nickname. You can do that like this:

     

     
    //get the currently logged in member
    XPathNodeIterator member = umbraco.library.GetCurrentMember();
    //set up a reader to read out the member's xml
    XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(member.Current.OuterXml));

    //move to the selected element
    reader.ReadToFollowing("nickname");
    //write the elements value
    Response.Write("Content of the element: " + reader.ReadElementContentAsString());

     

     

Please Sign in or register to post replies

Write your reply to:

Draft