Feed Subscribe
Exception has been thrown by the target of an invocation.

Getting rid of The current page has been customized warning in SharePoint 2010

by ondrejsv 26. December 2011 18:18

New WikiEditPage’s in SharePoint 2010 are great. Users finally may place web parts anywhere on the page and they don’t need any cumbersome ContentEditorWebPart’s with odd “Edit RTF” buttons.

There are times, however, when developers (or even power users from SPD) customize the page, to include some javascripts or other goodies. After customization of a WikiEditPage SharePoint shows a yellow warning (more precisely called status) in the display mode:


Not pretty. How to get rid of it? SharePoint supports an undocumented file property called “HidePageUnghostMessageV4”. Based on its name I suppose its sole purpose is to hide the message when the page is unghosted (i.e. customized). There seems to be a bug in the rendering code because when I set the property to “true”:


only the hyperlink for reverting disappears:


It’s possible that it’s not a bug but a feature but I would more appreciate if the flag worked by completely disabling the warning and not only the hyperlink.

The only way I know to turn off the warning now is to write a custom derived subclass of the SharePoint’s WikiEditPage that does not render the JavaScript for rendering the status warning (these messages are inserted in the status bar by calling the SP.UI.Status.addStatus JS function). WikiEditPage emits a little JavaScript code in the PreRender method by calling the well-known ScriptManager.RegisterStartupClientScriptBlock. Note that there is no way to unregister such a startup script. I mitigated this little complication by registering a startup script with the same key as WikiEditPage uses and with no body first, before the original PreRender code gets chance:

namespace Ondrejsv.CustomWikiEditPage { public class CustomWikiEditPage : WikiEditPage { protected override void OnPreRender(EventArgs e) { ScriptManager.RegisterStartupScript((Page)this, typeof(WikiEditPage), "unghostWarning", "", true); base.OnPreRender(e); } } }

The ordering of the statements is crucial here because if the base method call was first then the ScriptManager would emit the original script.

Don’t forget to place an entry into the SafeControl list, too. I created a Visual Studio solution for all of this and you may download it and deploy to your farm.

Now open your page in the SharePoint Designer and change the Inherits attribute in the Page directive from Microsoft.SharePoint.WebPartPages.WikiEditPage to Ondrejsv.CustomWikiEditPage.CustomWikIEditPage  (or whatever you call your custom class) and add a new Assembly directive for SharePoint to find the class (you may omit this directive if you place the full name in the Inherits attribute, of course):


No more the yellow pesky warning:


Note that any other warnings get displayed correctly:


Download the VS solution.


Comments (1) -

4/9/2012 11:41:27 PM #


Hi Ondrejsv!
I downloaded your zip file and we are trying to implement this solution. By chance would you happen to have this in a wsp file instead of a zip file??? If so, how could I get it? Please advise.

SB United States |

Comments are closed