Hi I have got a user contorl that is nicely rendering on the screen via a macro in umbraco.
But I want one of the felds on the form wich is a drop down list to be pre-populated with the names of some nodes that are in my content of my umbraco website, can someone please point me in the right direction.
Sorry if my intial question was unclear, let me try again.
I have a form which is a user control (.ascx file) and this usercontrol has been placed on a template, the form is rendering fine at the moment.
What I want to do is, load one of the form controls a drop down list with a list of node names.
I assume from the xslt above provided by Fuji I will have to use a umbrco library method to retrive the required data on the page_load event of my user control then use a loop to add them to my drop down list.........am I right?
I'm back 30mins later with my begging bowl, Yes I am getting the nodes that I want back, but I can't find where the name of the node will be so I can do some kind of loop and add the names of the nodes to a drop down list........
private void DoSomethingWithAllNodesByType(int NodeId, string typeName) { var node = new Node(nodeId); foreach (Node childNode in node.Children) { var child = childNode; if (child.NodeTypeAlias == typeName) { //Do something } if (child.Children.Count > 0) GetAllNodesByType(child, typeName); } } OK Fixed my own problem again.....Hope someone else finds this...who needs it chow.
We have a method called "uComponents.Core.uQuery.GetNodesByType(string documentTypeAlias)" ... this will get all the nodes for that doc-type alias. But if you need to do something more complex, say getting all child-nodes of a certain doc-type, then you could do this using an XPath ...
var nodes = uQuery.GetNodesByXPath(string.Concat("descendant::*[@id = ", nodeId ,"]/descendant::", documentTypeAlias, "[@isDoc]"));
Populate drop downlist with umbraco node names
Hi I have got a user contorl that is nicely rendering on the screen via a macro in umbraco.
But I want one of the felds on the form wich is a drop down list to be pre-populated with the names of some nodes that are in my content of my umbraco website, can someone please point me in the right direction.
Thanks
Hi Avo,
Do you mean a DropDownList on within Umbraco ? if so you could look at using the UltimatePicker or the XPath DropDownList (which is in uComponents)
HTH,.
Hendy
Hi Ayo,
You can try wrapping your select around a loop and get it to trigger like that
<select name="Name" id="yourId" onChange="window.open(this.options[this.selectedIndex].value,'_self')">
<option value="/">Make a choice</option>
<xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
<option value="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</option>
</xsl:for-each>
</select>
Sorry if my intial question was unclear, let me try again.
I have a form which is a user control (.ascx file) and this usercontrol has been placed on a template, the form is rendering fine at the moment.
What I want to do is, load one of the form controls a drop down list with a list of node names.
I assume from the xslt above provided by Fuji I will have to use a umbrco library method to retrive the required data on the page_load event of my user control then use a loop to add them to my drop down list.........am I right?
any c# code welcome ;-)
Thanks
using umbraco.presentation.nodeFactory;
I'm back 30mins later with my begging bowl, Yes I am getting the nodes that I want back, but I can't find where the name of the node will be so I can do some kind of loop and add the names of the nodes to a drop down list........
hellllppppppppp
thanks ;-)
Hey Ayo,
If you are using the uComponents package, then be sure to take a look at the uQuery library methods - they may just make your dev time easier? http://ucomponents.codeplex.com/wikipage?title=uQuery
We have a method called "uComponents.Core.uQuery.GetNodesByType(string documentTypeAlias)" ... this will get all the nodes for that doc-type alias. But if you need to do something more complex, say getting all child-nodes of a certain doc-type, then you could do this using an XPath ...
Cheers, Lee.
Have a look at this wiki post: http://our.umbraco.org/wiki/reference/code-snippets/databind-node-children. It shows 3 ways to databind the children to a checkboxlist. You can also use it for a dropdownlist.
Jeroen
is working on a reply...