Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a need to throw down a link in the right side bar of my page that will allow the user to put the page into edit mode. The edit page link in the site actions menu seems to do a postback to get the page into edit mode. My question is how can I put the current page into mode, or obtain a link that will have the same effect?

share|improve this question
add comment

2 Answers 2

I don't think you can put the page in edit mode by just clicking a link and without causing a server trip because the page needs to be checked out before it can be put in edit mode.

If you append following to current page url, page can be put in edit mode with a server trip and it might give a message if page is not checked out:

?ControlMode=edit&DisplayMode=design

UPDATE Based on Comments

How about using out of the box control which displays Edit button link when page is in display mode and save button when the page is in edit button. Using this you dont have to worry about checking states, permissions, display/hide etc.

<SharePoint:PageStateActionButton ID="PageStateActionButton" runat="server" Visible="false" />
share|improve this answer
    
I have no problem with doing a postback and redirect, I'm just looking for the code to take those actions. –  James Jan 12 '12 at 19:20
    
Thanks for that but I think that is a 2010 only construct, this solution has to work with 2007. –  James Jan 12 '12 at 20:52
add comment

Problem solved. Here was the solution I ended up using.

<a id="editPageLink" runat="server" href="javascript:switchToAuthoringMode();" class="edititem"><label></label>edit this page</a>

<script type="text/javascript">
    function switchToAuthoringMode() {

        if (document.forms['aspnetForm']['MSOLayout_InDesignMode'] != null)
            document.forms['aspnetForm']['MSOLayout_InDesignMode'].value = 1;
        if (document.forms['aspnetForm']['MSOAuthoringConsole_FormContext'] != null)
            document.forms['aspnetForm']['MSOAuthoringConsole_FormContext'].value = 1;
        if (document.forms['aspnetForm']['MSOSPWebPartManager_DisplayModeName'] != null)
            document.forms['aspnetForm']['MSOSPWebPartManager_DisplayModeName'].value = 'Design';

        <%= Page.ClientScript.GetPostBackEventReference(editPageLink, "EditCommunityPage", true) %>
    }
</script>
share|improve this answer
add comment

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.