Try our conversational search powered by Generative AI!

Get PropertyGroup programmaticly



I have problems to fetch PropertyGroups programmaticly and I dont know if I'm not understanding or if its a bug. I'm using PTB and EPi 6 R2 and I have a Propertygroup that looks like:


public class MyPropertyGroup : PageTypePropertyGroup
[PageTypeProperty(Type = typeof(PropertyPageReference), SortOrder = 10, DisplayInEditMode = false)]
public virtual PageReference FavoriteProperty { get; set; }




in my "main page" I do:

[PageType("<someguid>", Filename = "<some view path>", SortOrder = 1830)]
public classMyMainPageType : <BasePageType>,<Some interfaces>
[PageTypePropertyGroup(StartSortOrderFrom = 50)]

public virtual  <My return Property of propertyGroup>  FavoriteProperty { get; set; }





The problem I have is I have to fetch this property programmaticly from a pagedata extension method that has signature:

public static TProperty GetGroupPropertyValue<TPageData, TProperty>(this TPageData pageData, Expression<Func<TPageData, object>> expression)
where TPageData : TypedPageData, <Some interfaces>


and in that method I do:

 var value = pageData.GetPropertyValue<TProperty>(<nameOfProperty>); <nameOfProperty> is gotten in method by string manipulation and is in this case "MyPropertyGroup"

even if I can see that this property is set in editmode this method above returns null and I cant figure out whats wrong and will be happy if anyone could point me in right direction what to do to get PropertyGroups programmaticly



Jun 28, 2012 8:39

I'm not quite sure I follow but here are some things that might lead you in the right direction:

You're getting a property group wih the extension method GetPropertyValue. For property groups there is another extension method called GetPropertyGroupPropertyValue.

The name of the property that gets created consists of what you name the property group in your page as well as the actual property defined in the group. Let's say you have a property group called MyPropertyGroup with a property called MainBody. On your page type you add the property group MyPropertyGroup and name it ContactInfo. The property would then (if you look at it on page type in admin mode) be called ContactInfo-MainBody.

Does that help?

Jun 28, 2012 9:11



Is  "GetPropertyGroupPropertyValue"-extension-method supposed to be in PageTypeBuilder.PageDataExtensionMethods? Cant find this e-method in PTB 1.9.2?




Jun 28, 2012 11:32

Hmm, that may have come in v2 then (although I'm not certain). The methods themselves are in PageTypeBuilder.PageTypePropertyGroupExtensions.

Jun 28, 2012 12:53
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.