You can acces the base properties of a node by using myNode.Name, or myNode.Id, or myNode.NodeTypeAlias. Custom added properties are accessed by using the GetProperty() method. myNode.GetProperty("customProperty").Value.
Like I said, I tried to read the <items> using myNode.GetProperty("myPropertyAlias").Value.ToString() but it returns null. All the other properties of the node, custom or not, are ok.
I've been having the same experience as the original poster. What I've discovered through trial and error is...
The following works:
var content = new umbraco.cms.businesslogic.Content(1234); var prop = content.getProperty("Repeatable"); varval = prop.Value;
However, using the node factory does not:
var node = newNode(1234); var prop = n.GetProperty("Repeatable"); varval = prop.Value;
The value is null.
This is my first day using Umbraco, so I'd appreciate any insight why the node factory wouldn't work, as others claimed it would . The factory does work for the other properties in the node, just not the Repeatable Custom Content.
However, using the node factory does not:
var node = newNode(1234); var prop = n.GetProperty("Repeatable"); varval = prop.Value;
The value is null.
This is my first day using Umbraco, so I'd appreciate any insight why the node factory wouldn't work, as others claimed it would . The factory does work for the other properties in the node, just not the Repeatable Custom Content.
Hello, Masood. Yes, the other properties are correct. I'm fairly certain it's published -- if I use an XSLT macro, the Repeatable Custom Content values are populated with the expected content. I assume that means it's published.
To go in more detail: the content class is tha base class from the document class. The content class is also used by any other build in node in umbraco like the medias and the members (as I know).
@Thomas, thank you. I'm aware that I shouldn't use the cms name space, but rather the nodeFactory. In my post I stated the nodeFactory wasn't working for me, and I am trying to figure out why so that I may adhere to the best practices.
best practice is to use the nodefactory. So if you don't get the values it is another problem. Perhaps the xml isn't in sync. Try to recycle the app pool and republish the nodes. Also be sure that you have no typos for the properties, the aliases are case sensitive. So perhaps this is the problem. Hope you get it sorted :-)
Values for the repeatable content(s) is still always null. All the other doc types show the current values and the date verified with the nodes updateDate property.
Read <items> from usercontrol
Hi,
how can I read the <items> from a .net usercontrol? myNode.GetProperty("myPropertyAlias").Value.ToString() returns null. Version or Alias work fine.
Thank you!
You can acces the base properties of a node by using myNode.Name, or myNode.Id, or myNode.NodeTypeAlias. Custom added properties are accessed by using the GetProperty() method. myNode.GetProperty("customProperty").Value.
You can read a little more about the use of nodeFactory here http://our.umbraco.org/wiki/reference/api-cheatsheet/working-with-the-nodefactory
/Jan
Like I said, I tried to read the <items> using myNode.GetProperty("myPropertyAlias").Value.ToString() but it returns null. All the other properties of the node, custom or not, are ok.
bfi
Please check the database if there is any value or alternatively you can use xslt to confirm if it works in xslt?
As noted by Folkirt & Jan, myNode.GetProperty("customProperty").Value should work fine.
thanks
xslt sample is available at http://umbraco.masoodafzal.com/
I've been having the same experience as the original poster. What I've discovered through trial and error is...
The following works:
var content = new umbraco.cms.businesslogic.Content(1234);
var prop = content.getProperty("Repeatable");
var val = prop.Value;
var node = new Node(1234);
var prop = n.GetProperty("Repeatable");
var val = prop.Value;
The value is null.
This is my first day using Umbraco, so I'd appreciate any insight why the node factory wouldn't work, as others claimed it would . The factory does work for the other properties in the node, just not the Repeatable Custom Content.
However, using the node factory does not:
var node = new Node(1234);
var prop = n.GetProperty("Repeatable");
var val = prop.Value;
The value is null.
This is my first day using Umbraco, so I'd appreciate any insight why the node factory wouldn't work, as others claimed it would . The factory does work for the other properties in the node, just not the Repeatable Custom Content.
Sorry for the partial duplication in my above post; I hope you can tell where it should've ended. Are posts here not editable?
AbsCoder
Can you please confirm if other properties on same node return correct value? Just to check if node is published?
Masood
Hello, Masood. Yes, the other properties are correct. I'm fairly certain it's published -- if I use an XSLT macro, the Repeatable Custom Content values are populated with the expected content. I assume that means it's published.
Thank you!
First of all, you shouldn't use the umbraco.cms namespace for frontend retrieving of data (presentation). There you should use the NodeFactory mentioned by Jan before: http://our.umbraco.org/wiki/reference/api-cheatsheet/working-with-the-nodefactory
Dirk had a good blogpost about the difference: http://www.netaddicts.be/articles/document-api-vs-nodefactory.aspx
Second, if you are using the umbraco cms namespace you should use the umbraco.cms.businesslogic.web.Document...
Take a look into the wiki describing the usage of this namespace: http://our.umbraco.org/wiki/reference/api-cheatsheet
hth, Thomas
To go in more detail: the content class is tha base class from the document class. The content class is also used by any other build in node in umbraco like the medias and the members (as I know).
@Thomas, thank you. I'm aware that I shouldn't use the cms name space, but rather the nodeFactory. In my post I stated the nodeFactory wasn't working for me, and I am trying to figure out why so that I may adhere to the best practices.
best practice is to use the nodefactory. So if you don't get the values it is another problem. Perhaps the xml isn't in sync. Try to recycle the app pool and republish the nodes. Also be sure that you have no typos for the properties, the aliases are case sensitive. So perhaps this is the problem. Hope you get it sorted :-)
Tried both recyling the app pool and republishing before I posted. No room for typos when doing something like this...
Node myNode = new Node(1234);
var lit = new Literal();
lit.Text += "<b>PROPERTIES</b><br>";
lit.Text += "Node Updated: " + myNode.UpdateDate + "<hr />";
foreach (umbraco.presentation.nodeFactory.Property prop in myNode.Properties)
{
lit.Text += "Prop: " + prop.Alias + "<br />";
lit.Text += "Version: " + prop.Version.ToString() + "<br />";
if (prop.Value != null)
{
lit.Text += " Value: " + prop.Value + "<br />";
}
else
{
lit.Text += " Value: <b>IS NULL</b><br />";
}
}
lit.Text += "<hr />";
Values for the repeatable content(s) is still always null. All the other doc types show the current values and the date verified with the nodes updateDate property.
I have the same problem..has anyone found the solution yet?
Try something like:
Hi,
I can confirm having the same problem as AbsCoder i.e. the NodeFactory doesn't work dor this datatype.
And to answer the original question, this is how I have bound the items to a repeater:
Cheers
Paul
OK, I have tweaked my code from above to avoid using Document (and therefore use the XML cache instead and avoid a database hit). Here it is:
Seems to make a noticable difference performance wise even on localhost
Thanks Paul
is working on a reply...