Copied to clipboard

Flag this post as spam?

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


  • Henrik Bøgelund Lavstsen 8 posts 39 karma points
    Feb 19, 2010 @ 13:15
    Henrik Bøgelund Lavstsen
    1

    Getting the PageName inside a usercontroll

    Hey there

    As above, i cannot find the page name inside the Document, inside a usercontrol that i am making.

    i know how to get it inside templates which is like below:

    <umbraco:Item field="pageName" runat="server"></umbraco:Item>

    foreach (Document d in currentPage.Children)
                {
                 
                    dr = dt.NewRow();
                    dr["ID"] = id;
                    dr["StartDato"] = d.getProperty("StartDato").Value;
                    dr["SlutDato"] = d.getProperty("SlutDato").Value;
                    dr["BegivenhedsTitel"] =  <- i want the page name here
                    dt.Rows.Add(dr);
                    id++;
                }

    and sry forthe mixed danish into my code.

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Feb 19, 2010 @ 13:26
    Peter Dijksterhuis
    101

    Hi,

    I believe you can use d.Text for that.

    dr["BegivenhedsTitel"] = d.Text;

    HTH,

    Peter

  • Dennis Milandt 190 posts 517 karma points
    Feb 19, 2010 @ 13:38
    Dennis Milandt
    1

    Peter is right. The Text property is the node name of a Document.

    However, if you are working with published content you should work on the Node object rather than Document.

    Like this:

    var cur = Node.GetCurrent();
    var title = cur.Name;

    foreach(Node child in cur.Children)
    {
                    dr = dt.NewRow();
                    dr["ID"] = cur.Id;
                    dr["StartDato"] = cur.GetProperty("StartDato").Value;
                    dr["SlutDato"] = cur.GetProperty("SlutDato").Value;
                    dr["BegivenhedsTitel"] =  cur.Name
                    dt.Rows.Add(dr);
    }

    .. off the top of my head

  • Henrik Bøgelund Lavstsen 8 posts 39 karma points
    Feb 19, 2010 @ 14:22
    Henrik Bøgelund Lavstsen
    0

    Thank you for the reply, it was just the d.Text i needed.

    i already use the node.getcurrent on the document i run though the children with, and it works perfectly now.

Please Sign in or register to post replies

Write your reply to:

Draft