Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How can I check if a page is in ?pagepreview=true mode?

I've branded the sharepoint ribbon and need to check if a page is in pagepreview to get the site branded correct (js / css). Is there a way to do this without checking the url with JS

window.loaction.href.indexOf("?pagepreview=true") > -1
share|improve this question
4  
Are you asking if there is a different way to check it in JavaScript, or if there is a way to check it WITHOUT using JavaScript? Where are you checking for this, within a Content Editor Web Part? Within the master page? Where? – CigarDoug Jan 21 at 16:34

1 Answer

On the server side you can check QueryString params

[C#]
bool isPagePreviewMode = Convert.ToBoolean(HttpContext.Current.Request.QueryString["pagepreview"]);

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.