Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

Can i change inherited properties sortorder?

Vote:
 

Say I created a pagetype class which inherit from a baseclass which includes a property whos DisplayAttribute is set to 1.

Could i then access this propertys attribute and change to Order value in some way?


This is how my baseclass looks like:

    public class BaseContentPage : PageData
    {
        [Display(Name = "Innehåll", GroupName = SystemTabNames.Content, Order = 1)]
        public virtual ContentBlock MainContent { get; set; }

        [Display(Name = "Listning", GroupName = Global.CustomTabName.Listing, Order = 2)]
        public virtual ListingBlock Listing { get; set; }
    }

and this is my new pagetype

    public class EventPageType : BaseContentPage
    {
        [CultureSpecific]
        [Editable(true)]
        [Display(
            Name = "Startdatum",
            Description = "Datum då evenamanget startar",
            GroupName = SystemTabNames.Content,
            Order = 1)]
        public virtual DateTime StartDate { get; set; }
        
        [CultureSpecific]
        [Editable(true)]
        [Display(
            Name = "Slutdatum",
            Description = "Datum då evenemanget slutar",
            GroupName = SystemTabNames.Content,
            Order = 2)]
        public virtual DateTime EndDate { get; set; }

}

 

So lets say i wanted StartDate and EndDate in my new pagetype to be displayed before the ContentBlock of my baseclass. Is this possible?

#79950
Jan 10, 2014 14:10
Vote:
 

The properties are virtual, so yes, you can override them.

But I would suggest to multiply SortOrder by 100 (or something else) for each super class and start on 100 in your base class. So:

public class BaseContentPage : PageData
    {
        [Display(Name = "Innehåll", GroupName = SystemTabNames.Content, Order = 100)]
        public virtual ContentBlock MainContent { get; set; }

        [Display(Name = "Listning", GroupName = Global.CustomTabName.Listing, Order = 110)]
        public virtual ListingBlock Listing { get; set; }
    }

    

public class EventPageType : BaseContentPage
{
        [CultureSpecific]
        [Display(
            Name = "Startdatum",
            Description = "Datum då evenamanget startar",
            GroupName = SystemTabNames.Content,
            Order = 80)]
        public virtual DateTime StartDate { get; set; }
        
        [CultureSpecific]
        [Display(
            Name = "Slutdatum",
            Description = "Datum då evenemanget slutar",
            GroupName = SystemTabNames.Content,
            Order = 90)]
        public virtual DateTime EndDate { get; set; }

        [Display(Order = 200)]
        public virtual string Property1 { get; set; }

        [Display(Order = 210)]
        public virtual string Property2 { get; set; }

}

    

#79964
Edited, Jan 11, 2014 1:27
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.