many thanks for sending me this code, but i am having a compile time error like bellow ?
Error 1 The type 'umbraco.interfaces.INode' is defined in an assembly that is not referenced. You must add a reference to assembly 'interfaces, Version=1.0.4085.20549, Culture=neutral, PublicKeyToken=null'.
here are my full code ....
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using umbraco; using umbraco.NodeFactory;
namespace custom_controls { public partial class ucpagehierachy : System.Web.UI.UserControl {
i am writing this code in my own web project,, once i write my user controls then i copy in to the relavant umbraco site /usercontrols folder and then copy the .dll file in to the /bin directory ...
ok make sure you have referenced all the necessary DLLs ... in your references folder have you included the right DLLs ? looks like you may have missed out the interfaces dll
list of all the pages in user control
hi all ,
if i have a bellow hierachy of pages in my umbraco admin panel
Home
Story
SiteMap
Shop
WebShop
MediaShop
ContactUs
now my question is how do i load this same hierachy in to a treeview on my own user control ?
regards
suisrad
hi all,
if i use this code,i can get all the main pages in my hierachy .... it wont add any child pages like webshop,MediaShop etc ...
umbraco.presentation.nodeFactory.Node node = new umbraco.presentation.nodeFactory.Node(1070);
umbraco.presentation.nodeFactory.Nodes childrenNodes = node.Children;
foreach (umbraco.presentation.nodeFactory.Node n in childrenNodes)
{
TreeView1.Nodes.Add(new TreeNode(n.Name, n.Id.ToString()));
TreeView1.DataBind();
}
please help for me to sort this out ?
regards
sukavi
Hi Sukavi. You will need to make a function which you can recursily call from itself. Something on the lines of
hi asif,
many thanks for sending me this code, but i am having a compile time error like bellow ?
Error 1 The type 'umbraco.interfaces.INode' is defined in an assembly that is not referenced. You must add a reference to assembly 'interfaces, Version=1.0.4085.20549, Culture=neutral, PublicKeyToken=null'.
here are my full code ....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using umbraco;
using umbraco.NodeFactory;
namespace custom_controls
{
public partial class ucpagehierachy : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void BuildTreeView()
{
umbraco.presentation.nodeFactory.Node startNode = new umbraco.presentation.nodeFactory.Node(1070);
GetChildren(startNode);
TreeView1.DataBind();
}
private void GetChildren(Node startNode)
{
foreach (Node childNode in startNode.Children)
{
TreeView1.Nodes.Add(new TreeNode(childNode.Name, childNode.Id.ToString()));
if (childNode.Children.Count > 0)
{
GetChildren(childNode);
}
}
}
}
}
try adding
using umbraco.BusinessLogic;
hi asif,
my umbraco version is 4.7.1 any idea for this compilation error ?
thanks
regards
sukavi
I assume the above didnt help
Where are you adding this code ? have you created a user control inside the usercontrols folder ? is your project a website, or a web application ?
try replacing
umbraco.presentation.nodeFactory.Node startNode = new umbraco.presentation.nodeFactory.Node(1070);
with
umbraco.NodeFactory.Node startNode = new umbraco.NodeFactory.Node(1070);
hi asif,
i am writing this code in my own web project,, once i write my user controls then i copy in to the relavant umbraco site /usercontrols folder and then copy the .dll file in to the /bin directory ...
regards
sukavi
i have replaced with this
umbraco.NodeFactory.Node startNode = new umbraco.NodeFactory.Node(1070);
but it didnt help me ,
compilation error is pointing to the this method GetChildren()
regards
sukavi.
ok make sure you have referenced all the necessary DLLs ... in your references folder have you included the right DLLs ? looks like you may have missed out the interfaces dll
hi asif,
thanks for the help,
copilation error gone after i added the interfaces.dll as a reference ,
but i dont think that recursion logic is right ...its not adding any child nodex to my treeview.... i can see every pages are coming on same level ,
any ides ?
regards
sukavi
That was just some quick code, you may want to add them to a global variable and then use that as the datasource for the TreeView,
thanks for help u r kind i will add my own code to sort it out ...
regards
sukavi ...
is working on a reply...