Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Display warning message in edit mode


During releases, we want to prevent editors from publishing anything for a short period, in order to prevent loss of data (the EPiServer database is replicated between environments).

We have accomplished this attaching to the event DataFactory.Instance.PublishedPage in Global.asax, and in our attached method checking the status of a flag in our database. If the flag is raised, we simply set "e.CancelAction = true" and provide a custom message in "e.CancelReason". All ok so far.

However, in addition to this, we would like to notify the editors that publishing has been disabled as soon as they enter edit mode for an article, to discourage them from doing any work on the content at all (after all, it can't be published anyway). In CMS 4.62, this was easily accomplished by attaching to "Global.EditPageValidators" in Global.asax, like this: Global.EditPageValidators += new PageValidateEventHandler(Global_EditPageValidators); Then, in our attached method, we would set "e.IsValid=false" and provide a custom warning message to "e.ErrorMessage" if the flag in our database was raised.

However, I cannot for the life of me figure out how to accomplish the same thing in CMS 5 R2! It's probably a simple thing, once you know what to attach where, but I'm getting lost in the SDK..

Any help would be much appreciated! :-)


Dec 01, 2010 18:58


You can probably attach to the EPiServer.UI.Edit.EditPanel.LoadedPage event where you will get a refrence to the EditPanel instance:

public delegate void LoadedPageEventHandler(EditPanel sender, LoadedPageEventArgs e);

Here you should be able to check your flag and as some sort of a message to the editor.

Linus Ekström
EPiServer Development Team

Dec 02, 2010 7:29

Excellent, that was the event I was looking for. However, I still cannot figure out how to add a warning message to the top of the page. I have searched and searched, and I have found another post which asks the same (, but no answers.

Any suggestions?

Dec 02, 2010 10:21


There does not seem to be any public method to add warning messages but you can achieve this by adding a static validator:

void EditPanel_LoadedPage(EPiServer.UI.Edit.EditPanel sender, EPiServer.UI.Edit.LoadedPageEventArgs e)
    sender.Validators.Add(new StaticValidator("Some error message"));


Dec 02, 2010 10:35

One dirty way of doing it is to look at this on page 25

Dec 02, 2010 11:28

Excellent, thank you very much.

I tried Linus' suggestion, and it works like a charm - just what I needed :-)

Dec 02, 2010 12:10
* 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.