CodeGarden 10: The sixth annual Umbraco Developer Conference
June 23-25th 2010 - free ASP.NET MVC pre-conference. Register today!

read items from usercontrol

10/22/2009 4:08:08 PMAvatarbfiLocation: rotterdam, the netherlandsposts: 44Karma: 52

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!

10/22/2009 5:12:33 PMAvatarFolkertLocation: Amsterdamposts: 27Karma: 48
Comment with ID: 17533

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.

10/22/2009 5:16:40 PMAvatarJan SkovgaardLocation: Viby j, Denmarkposts: 450Karma: 1978
Comment with ID: 17534

You can read a little more about the use of nodeFactory here our.umbraco.org/.../working-with-the-nodefactory

/Jan

10/23/2009 9:27:36 AMAvatarbfiLocation: rotterdam, the netherlandsposts: 44Karma: 52
Comment with ID: 17579

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.

10/26/2009 8:15:46 PMAvatarMasood AfzalLocation: Glasgow, UKposts: 128Karma: 316
Comment with ID: 17775

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

 

 

 

10/26/2009 8:16:40 PMAvatarMasood AfzalLocation: Glasgow, UKposts: 128Karma: 316
Comment with ID: 17776

xslt sample is available at http://umbraco.masoodafzal.com/

 

 

2/8/2010 9:41:03 PMAvatarAbsCoderLocation: 85286posts: 5Karma: 25
Comment with ID: 25714

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;

 

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.

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.

 

2/8/2010 9:49:22 PMAvatarAbsCoderLocation: 85286posts: 5Karma: 25
Comment with ID: 25716

Sorry for the partial duplication in my above post; I hope you can tell where it should've ended. Are posts here not editable?

2/8/2010 10:10:12 PMAvatarMasood AfzalLocation: Glasgow, UKposts: 128Karma: 316
Comment with ID: 25719

AbsCoder

Can you please confirm if other properties on same node return correct value? Just to check if node is published?

Masood

2/8/2010 10:32:56 PMAvatarAbsCoderLocation: 85286posts: 5Karma: 25
Comment with ID: 25721

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!

2/8/2010 11:29:48 PMAvatarThomas HöhlerLocation: Bad Homburg, Germanyposts: 1086Karma: 1279
Comment with ID: 25724

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: our.umbraco.org/.../working-with-the-nodefactory

Dirk had a good blogpost about the difference: www.netaddicts.be/.../...t-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: our.umbraco.org/wiki/reference/api-cheatsheet

hth, Thomas

Pages:

Please login or Sign up To post replies