Pagetype event handler

Martin Varecka asked on September 29, 2017 14:09


I have PageType "custom.Pool" which share parameters for other cultures (like width, length, height...). When user change parameters in main culture (for me cs-Cz) I need change this parameters in other cultures.

I'm using event handlers. I tryed to use PageTypeInfo (generated from tab Code).

Pool.TYPEINFO.Events.Update.After += Pool_Update_After;


private void Pool_Update_After(object sender, ObjectEventArgs e) {
  var pool = (Pool)e.Object;
  if (pool.DocumentCulture == UglyConstants.MainCulture) {
    var cultures = pool.CultureVersions;
    foreach (var c in cultures) {
      if (c.DocumentCulture != UglyConstants.MainCulture) {
        var p = (Pool)c;
        p.PoolMSHeight = pool.PoolMSHeight;
        p.PoolMSWidth = pool.PoolMSWidth;
        p.PoolMSLength = pool.PoolMSLength;
        p.PoolMSVolume = pool.PoolMSVolume;
        p.PoolMSWeight = pool.PoolMSWeight;


Unfortunately this not work for me.

But this work fine. DocumentEvents.Update.After += Update_After;

Is here any way, how to do it with PageTypeInfo? (I have a lot of PageTypes).

Thank you.

Recent Answers

Rui Wang answered on September 29, 2017 15:19 (last edited on September 29, 2017 15:29)

You can use DocumentEvents.Update.After += Update_After; then you do a check for if classname = custom.pool, then call your pool_update method.

Or, how did you create the "pool" class for your TYPEINFO? Did you created it using the builtin code generator or created it on your own? ( which you should generate PoolInfo class.

2 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 29, 2017 17:04 (last edited on October 1, 2017 06:51)

I'd say go with what works. Do a switch statement in your event function and check for the classname to perform you actions.

If you're using workflow you will have to use a different event handler as the documentation suggests.

For example, to handle the 'update' action for a page under workflow, use the SaveVersion event from WorkflowEvents instead of the DocumentEvents.Update event.

0 votesVote for this answer Mark as a Correct answer

Martin Varecka answered on September 29, 2017 17:12

Thank you for your response.

I used builtin code generator (pagetype -> custom.pool -> code).

Yes I know about class name, but I have about 12 pagetypes. It means make huge switch.

So I'm looking for options with PageTypeInfo - Pool.

Any suggestions?

Thank you.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on October 1, 2017 20:55

But you are not changing the actual page type definition, right? The user is changing some actual value in one of the pages, represented by given page types. Just to be sure, the user is not adding any fields to the page type, is this correct?
If yes, the user is editing the page object, not the page type. The page type is just the data structure container and the event is not fired.
So, as Rui suggested you need to use the document (pages) event handler in this case and do the check on the NodeClassID to check if given updated page is matching your page type.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.