Try our conversational search powered by Generative AI!

How to distribute page properties to other classes?

Vote:
 

If I have an EPiServer page which contains a lot of properties, can I distribute the properties into subclasses to not have them all in one place?

It's an SPA and no blocks are used.

#177411
Apr 11, 2017 10:11
Vote:
 

You can use normal inheritance with properties with the page class having both its own properties and the ones defined in a  base class.

You can also group related properties into blocks that are used as part of the page. It all depends on what you are trying to do.

#177413
Apr 11, 2017 10:32
Vote:
 

A base class won't do. I'll need to distribute the page properties into multiple classes if possible. Then I will put 4-6 properties in each class. I'd like for every class to have a tab also.

Then each SPA view will have it's own class (and tab), but the classes all hang on the same EPiServer page which functions as a container.

I'd like not to use blocks for this.

#177432
Apr 11, 2017 13:49
Vote:
 

Hi Bo,

It is possible to use partial classes in episerver cms.

For tabs, you can check out this link: http://world.episerver.com/blogs/Per-Bjurstrom/2015/2/typed-tabsgroups/

#177436
Apr 11, 2017 14:09
Vote:
 

Tabs are assigned by decorating the propery with the Display attribute and setting its GroupName property. You can't split the class but you could declare the class partial to split the properties into multiple code files if that is any help. And you can of course use custom model classes for your views instead of the page class itself if you want to structure the data in another way.

If you really want to split the properties across multiple classes, you could use multiple pages (of different page types) even if only one of them has a view. This "main" page could have properties pointing to the other pages containing the additional data.

#177437
Apr 11, 2017 14:10
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.