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

This is a real long-shot, but here goes.

I followed this tutorial: httpcode.msdn.microsoft.comAdding-default-web-parts-ab7aec72#content

And successfully, have incorporated the server control into my page layouts mentioned in order to define a 'default' web part for the web part zone defined on my page layout.

The one problem I'm having is that when a user chooses to add a 'New Page' and then chooses the page layout in question - the web part zones are not actually in edit mode (despite the fact that the query strings do define ControlMode as Edit and DisplayMode as Design).

The one way I've found around this is to append &ToolPaneView=3 onto the query string - but as you may know - this then displays the 'Add Web Parts' dialog - and this isn't something that fits the spec.

If anyone knows of any other ways I can taket he user to a display mode were the web part zones are automatically editable I'd really really appreciate it.

EDIT: I've also tried the Contents=1 parameter, with no luck.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

This is the code i've used before to make a page layout editable only when being displayed in a modal. You should be able to get what you need from it:

        function ChangeToEditMode(){
            if (window.location.search.match("[?&]PageView=Shared")){
                var inDesignMode = document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value; 

                if (inDesignMode == "1") 
                { 
                    // page is in edit mode 
                } 
                else 
                { 
                    SP.UI.ModalDialog.commonModalDialogClose(1, null); 
                } 
            }
            else{
                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";
                ChangeLayoutMode(false);                
            }
        }


        if (window.location.search.match("[?&]IsDlg=1")) {
            ExecuteOrDelayUntilScriptLoaded(ChangeToEditMode, "sp.js");
        }
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.