Copied to clipboard

Flag this post as spam?

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


  • praveen 113 posts 164 karma points
    Jul 21, 2011 @ 02:59
    praveen
    0

    CSharp Code to loop through nodes

    Hi

    I need some Csharp code to do the following:

    For example I want to start from "FGM Education Resources for Health Care Proffessionals" and read the Document property of this node, the loop through all its child nodes.

    And I want to do the same thing with next sub node "FGM Education Resources for Community Education"

    Many thanks for your help in advance

    Kind regards

    Praveen

  • praveen 113 posts 164 karma points
    Jul 21, 2011 @ 05:18
    praveen
    0

    Hi There

    umbraco 4.7 / visual studio 2010

    I wote some csharpe code but it prints all the parents first and the prnts the child nodes,

    what I want is to print each parent and then prints its childrens, can someone please advice on the following code.

    private void Populate()
            {
                umbraco.NodeFactory.Node CurNode = umbraco.NodeFactory.Node.GetCurrent();
                umbraco.NodeFactory.Nodes ChNodes = CurNode.Children;

                foreach (umbraco.NodeFactory.Node doc in ChNodes)
                {
                    if (doc.Children.Count > 1)
                    {
                        Label1.Text += doc.Name + "--"; //Print the header

                        umbraco.NodeFactory.Nodes SubNodes = doc.Children;
                        foreach (umbraco.NodeFactory.Node sdoc in SubNodes)
                        {
                            Label2.Text += sdoc.Name + "--";  //Print the children of each parent
                        }
                    }
                }
            }

    Many thanks for your help

    Regards

    Praveen

  • praveen 113 posts 164 karma points
    Jul 21, 2011 @ 06:11
    praveen
    0

    Nailed this one;)

    This code works :)

            private void Populate()
            {
                umbraco.NodeFactory.Node CurNode = umbraco.NodeFactory.Node.GetCurrent();
                umbraco.NodeFactory.Nodes ChNodes = CurNode.Children;

                foreach (umbraco.NodeFactory.Node doc in ChNodes)
                {
                    Label1.Text += "<b>" + doc.Name + "</b><br />"; //Print the header

                        //umbraco.NodeFactory.Nodes SubNodes = doc.Children;
                        //foreach (umbraco.NodeFactory.Node sdoc in SubNodes)
                        foreach (umbraco.NodeFactory.Node sdoc in doc.Children)
                        {
                            Label1.Text += sdoc.Name + "<br />";  //Print the children of each parent
                        }

                }
            }

  • johnag 2 posts 22 karma points
    Apr 12, 2013 @ 15:56
    johnag
    0

    Behandling med Sciton IPL er mer behagelig og tryggere enn vanlig IPL på grunn av innebygd kjøling i behandlingshodet. Dette gjør også at vi kan bruke mer energi og gå dypere i behandlingsområdet uten at det fører til skader på huden.www.kolibrimedical.com,vitalhudklinikk.no,cosmedica.no.

Please Sign in or register to post replies

Write your reply to:

Draft