Skip Ribbon Commands
Skip to main content

Tanmay Shahane | zevenseas | SharePoint Blog

:

Tanmay Shahane | zevenseas | SharePoint Blog > Posts > Check if page is in Edit Mode on Client Side in SharePoint 2010
September 28
Check if page is in Edit Mode on Client Side in SharePoint 2010

 

Hello kind readers…
 
Lately we had a requirement where we wanted to do some JavaScript and CSS tricks when the page was in edit mode…. Now for this we needed to check if currently the page was in Edit Mode… now there are couple of ways of doing this using the object model or Client object model … but adding extra code processing just for a simple requirement was something I was not feeling good about…. So I cracked open page  html source … the best place to find info what SharePoint already  renders… Some time back I did a post on useful variable in SharePoint 2010 … but yet there are more and it is one of the JavaScript variables that came to my rescue…
 
So cutting  it short… basically  there is a JavaScript variable g_disableCheckoutInEditMode which is present on the page by SharePoint 2010 which is set to False when page is in checked in mode ... and the moment you check out the page for edit this variable is set to True by SharePoint itself when the page is rendered… so now since the information was already present on the page .. No need for any extra calls and a simple way to do was…
 
 
If(g_disableCheckoutInEditMode)
 {
        
//Do some client side JQuery logic as page is in Edit mode
}
Else
{
        
//Do some logic when page is in checked in mode
}
 
So you can easily do some customization when you want to do some client side scripting based on page edit mode… you can easily call some Client object model code also from here in case you want to so particular operations… reasons can be plenty…
 
Hope this is useful to someone in some way!!
 
           -"T"

Comments

awesome

awesome mate, Thanks, really helps
Faiyaz
 on 10/13/2011 10:05 AM

Re: Check if page is in Edit Mode on Client Side in SharePoint 2010

Thanks Faiyaz! :)
 on 10/19/2011 3:08 AM

Thanks!

Was super helpful. Just what i needed.
 on 4/3/2012 11:17 AM

hum...

not work on firefox in anonymous mode
 on 5/7/2012 9:17 AM

Christian Louboutin Boots On Sale


My partner and i take a nap, please take a straw head wear, along with buckles face,desire grass inside Hong Kong. I came to be to depart you, Once you enter in the path involving crimson dirt,   Christian Louboutin Boots On Sale   the actual wind chime because i tend not to invest the particular wedding ring.While this individual came up, This individual shook his / her head in a very vast natrual enviroment road, and smiled. I will be myself, you did not maintain myself in a aspiration.
http://www.zamshoes.com/ Christian Louboutin Boots On Sale
http://www.zamshoes.com/categories-pumps.html black christian louboutin pumps sale
http://www.zamshoes.com/categories-boots.html christian louboutin boots on sale
http://www.zamshoes.com/categories-for-men.html  christian louboutin men
http://www.zamshoes.com/categories-sneakers.html christian louboutin sneakers sale
http://www.zamshoes.com/categories-flats.html christian louboutin flats cheap
http://www.zamshoes.com/miu-miu-shoes.html miu miu shoes outlet
http://www.zamshoes.com/jimmy-choo.html jimmy choo shoes on sale
http://www.zamshoes.com/manolo-blahnik.html manolo blahnik something blue
 on 11/4/2012 4:41 PM

1

1
 on 3/7/2013 4:33 AM

1

1
 on 3/7/2013 4:33 AM

1

1
 on 3/7/2013 4:34 AM

1

1
 on 3/7/2013 4:34 AM

Add Comment

Title


Body *


Attachments

 

 Related Posts

 
 

 Statistics

 
Views: 2690
Comments: 9
Tags:SharePoint 2010, JavaScript
Published:601 Days Ago