3

Like in topic.

How to determine in a client web part (on remote web) if a page that the web part is placed on, is in edit mode? if it is possible??

Thanks

  • SharePoint 2013 - writing Client Web Part I mean App Part used in Provider-hosted App – quest May 29 '13 at 12:31
  • check this link out if it helps, sharepoint.stackexchange.com/questions/12792/… – Muhammad Raja May 29 '13 at 12:31
  • this is good solution when you developing sharepoint solutions. In SharePoint App it doesn't work because page that is displayed in web part is hosted outside of sharepoint so it hasn't SharePoint's context.... – quest May 29 '13 at 12:54
  • if the page isn't in SharePoint context then how user edit's it ? – Muhammad Raja May 29 '13 at 13:04
3

You can determine if your client web part is in edit mode (when your client web part is being edited).

Unfortunately there is no way to determine if the host web page is being edited. There is a blog post about it at sharapointalist.com

What you have to do is to add an additional token to your client web part:

&editmode=_editMode_

<ClientWebPart Name="ClientWebPart" 
               Title="TestAppPart" 
               Description="TestAppPart" 
               DefaultWidth="600" DefaultHeight="300">

  <Content Type="html" 
       Src="~appWebUrl/Pages/DemoPage.aspx?{StandardTokens}&amp;editmode=_editMode_" />

  <Properties>
  </Properties>

</ClientWebPart>

Then you have to get this editmode query string, you can do it with getQueryStringParameter function which is "shipped" within the default sharepoint app template in Visual Studio:

function getQueryStringParameter(paramToRetrieve) {
    var params =
        document.URL.split("?")[1].split("&");
    var strParams = "";
    for (var i = 0; i < params.length; i = i + 1) {
        var singleParam = params[i].split("=");
        if (singleParam[0] == paramToRetrieve)
            return singleParam[1];
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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