November Happy Hour will be moved to Thursday December 5th.

Why can't I bind an event handler to SavingPage?

Vote:
 

I think I'm going a little crazy --

I cannot, for the life of me, get an event handler to bind to SavingPage.  Consider this code:

[PagePlugIn]
public class MyClass
{
public static void Initialize(int bitflags)
{
DataFactory.Instance.SavingPage += new PageEventHandler(MyMethod);
}

etc.

}

I hit "Save and Publish,", but the event handler never fires. I've debugged, with a breakpoint, and it just never gets hit. (I assume "Save and Publish" runs the SavingPage event somewhere.)

Here's the weird thing: I can bind to PublishingPage. So, PublishingPage works, but SavingPage does not.  Take the above code, change "SavingPage" to "PublishingPage," and it will work fine.

I tried binding in global.asax.  Still, it won't bind.  It doesn't throw an error, but it will not bind the event handler.

I got really creative and bound to PublishingPage, then inside that event handler, bound it again to SavingPage.  I debugged, and watched the code cross that line, so I know the code ran.

I know I'm missing something simple.

CMS 6 with Composer Beta 4 installed.

 

#40947
Jun 24, 2010 0:40
Vote:
 

You are not doing anything wrong, it's just a feature in EPiServer....

When you create a new page, the SavingPage event does NOT get fired. It only fires the CreatingPage.  If you go to an existing page, edit that page and press save and publish, you will get the SavingPage event as expected.

#40948
Jun 24, 2010 7:48
Vote:
 

Yep, that was it.  I knew it was something simple I was missing.

Thanks Lars.

#40953
Jun 24, 2010 8:32
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.