Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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.
Hi,
I believe you can use d.Text for that.
dr["BegivenhedsTitel"] = d.Text;
HTH,
Peter
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
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.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
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.
Hi,
I believe you can use d.Text for that.
dr["BegivenhedsTitel"] = d.Text;
HTH,
Peter
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
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.
is working on a reply...