Programmatically accessing Property types

Vote:
 

Hi,

I'd like to programmatically access the type of a property. So I'll fetch the property the conventional way, and then I'd like to grab the bit that specifies whether it's:

 

  1.  URL to Image
  2. URL to Page / External Address
and so on.
 
Can anybody tell me how to grab this?
 
Cheers for any help in advance,
 
Karl. 

 

#31156
Jul 06, 2009 14:29
Vote:
 

While I'm at it, I also need to access the tab it belongs to. So when adding a property, it's the dropdown that is labelled with:

"Place under heading:"

Any ideas?

Cheers! 

#31157
Jul 06, 2009 15:01
Vote:
 

Hi Karl!

Let's see, you should be able to get them using something like this:

Tab:
TabDefinition tab = CurrentPage.Property["myProp"].Tab;

Property type name:
string propTypeName = PageDefinition.Load(CurrentPage.Property["myProp"].PageDefinitionID).Type.LocalizedName;

I've not actually tested this, so I may have made some stupid error, but something along those lines should give you what you want.

Regards

Per Gunsarfs
EPiServer CMS development team

#31165
Jul 06, 2009 16:59
Vote:
 

Hi Per,

Thanks for getting back to me so quickly!

I've tried both of those suggestions, but no luck.

 There's no tab property, but there is a ownertab property!

 

I used this:
TabDefinition tab = TabDefinition.Load(propData.OwnerTab);

And for my type, that code worked exactly, though I had to catch the empty types!

Thanks very much!

Cheers,

Karl. 

#31169
Jul 06, 2009 17:31
Vote:
 

Hi

Sorry, doublechecked and you are correct there is no Tab property on PropertyData, don't know how I read the SDK yesterday. It's of course PageDefinition that has a Tab property But it seems like you solved your problems anyway :)

If these kind of problems my suggestion is to start with the classes PropertyData and PageDefinition. From there you can get most such information.

Regards

Per Gunsarfs

#31178
Jul 07, 2009 9:22
Vote:
 

Yep, all sorted!

Thanks anyway Per,

Karl 

#31180
Jul 07, 2009 10:56
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.