Try our conversational search powered by Generative AI!

SetDefaultValues for PageType property


Not sure how to go about setting a default value for a PageType property

For example:

[ContentType(DisplayName = "Article Page")]
public class Article : PageData
    public virtual string Heading { get; set; }
    public virtual XhtmlString MainBody { get; set; }
public virtual PageType PageTypeFilter { get; set; }

    public override void SetDefaultValues(ContentType pageType)

        Heading = "My awesome article";
        MainBody = new XhtmlString(" Enter your article text here");
PageTypeFilter = not sure how to set this

The PageType property provides drop down list of all the page types.

How do you have one selected by default, or force the dropdown to only show a subset of pagetypes/


Feb 24, 2016 3:50

You can always use a selection factory to control the options.

Feb 24, 2016 7:02

If you do that one you get full control of your drop-down but a little more work. You can use 

var repository = ServiceLocator.Current.GetInstance<PageTypeRepository>();

Use the list method to generate the options

Then either set default value like you do or set it in factory. It's hidden in the metadata object and called initial value.

Feb 24, 2016 7:28

Great, thanks Daniel. Yes, this works:

            var repository = ServiceLocator.Current.GetInstance<PageTypeRepository>();
            PageTypeFilter = repository.Load<MyPageType>();

I guess you could also use the List method then use Linq to filter it,


Feb 26, 2016 6:04
* 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.