Programmatically accessing Property types

Karl Alesbury
Member since: 2009


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,


#31156 Jul 06, 2009 14:29
  • Karl Alesbury
    Member since: 2009

    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?


    #31157 Jul 06, 2009 15:01
  • Per Gunsarfs
    Member since: 2005

    Hi Karl!

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

    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.


    Per Gunsarfs
    EPiServer CMS development team

    #31165 Jul 06, 2009 16:59
  • Karl Alesbury
    Member since: 2009

    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!



    #31169 Jul 06, 2009 17:31
  • Per Gunsarfs
    Member since: 2005


    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.


    Per Gunsarfs

    #31178 Jul 07, 2009 9:22
  • Karl Alesbury
    Member since: 2009

    Yep, all sorted!

    Thanks anyway Per,


    #31180 Jul 07, 2009 10:56