I am quite new to umbraco. I am using uCompontents but struggling to access it in code behind .ascx control. Can't find anywhere how to access it. Can anyone please let me know which .dll files to reference to access uComponents more specifically I need to access related nodes from Multi-Node Tree Picker in code behind.
I am using Multi-Node Tree Picker as csv so an example with that would be helpful.
Here's an example of how to use the MNTP value (CSV) from a user-control's code-behind. Since you are using uComponents, we can make use of uQuery too!
using System;
using uComponents.Core;
using uComponents.Core.uQueryExtensions;
using umbraco.presentation.nodeFactory;
public partial class usercontrols_WebUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
// get the current node
var currentNode = Node.GetCurrent();
// use uQuery to get the value from MNTP
var csv = currentNode.GetPropertyAsString("treePicker");
// use uQuery to get the nodes by CSV
var nodes = uQuery.GetNodesByCsv(csv);
// loop through each of the nodes
foreach (var node in nodes)
{
// do whatever you like with the node!
Response.Write(node.Name + "<br />");
}
}
}
You will need to reference the "uComponents.Core.dll", (along with "umbraco.dll") in your Visual Studio project.
Multi-Node Tree Picker in .ascx code behind
Hi,
I am quite new to umbraco. I am using uCompontents but struggling to access it in code behind .ascx control. Can't find anywhere how to access it. Can anyone please let me know which .dll files to reference to access uComponents more specifically I need to access related nodes from Multi-Node Tree Picker in code behind.
I am using Multi-Node Tree Picker as csv so an example with that would be helpful.
Thanks.
Hi Wagar,
Here's an example of how to use the MNTP value (CSV) from a user-control's code-behind. Since you are using uComponents, we can make use of uQuery too!
You will need to reference the "uComponents.Core.dll", (along with "umbraco.dll") in your Visual Studio project.
Cheers, Lee.
is working on a reply...