Scott
Scott

Reputation: 1021

How to know if save was clicked in Content Editor or Page Editor in saveUI processor

I have a saveUI processor and I only want to run my code if the user clicked the save button in Page Editor. I've tried checking the context like:

Sitecore.Context.PageMode.IsPageEditor

but it's always false. My guess is that the processor isn't in the right context.

How do I go about checking where the click was from? Is the "sender" indicated in the args somewhere?

Upvotes: 3

Views: 727

Answers (1)

Jonathan Robbins
Jonathan Robbins

Reputation: 2047

You should be able to correctly detect the PageMode in the Sitecore Context via

if (Sitecore.Context.PageMode.IsPageEditorEditing)

There are also options like

  • IsPageEditor
  • IsPageEditorDesigning
  • IsPageEditorClassic

If you have a look in the Sitecore.Context.PageMode namespace you will see all the options available to you so you can detect the mode you need.

I believe for older versions of Sitecore (possibly 6.5 and below) there were different properties.

I recommend looking at this post for additional information - https://www.sitecore.net/learn/blogs/technical-blogs/martina-welander-sitecore-blog/posts/2013/07/improving-the-page-editor-experience-part-3-detecting-page-mode.aspx

Upvotes: 1

Related Questions