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

The WebPartPages Web service includes actions to get or save Web Part properties (GetWebPart, SaveWebPart). Both require a unique identifier called storageKey.

When using Web services on the client side (JavaScript/jQuery), how can I retrieve this storageKey?

Thanks!

share|improve this question
add comment

3 Answers

up vote 0 down vote accepted

The Storage key is a guid. The value of it is the same as the value of WebPartID attribute of the div representing the web part.

share|improve this answer
    
I tried in SP Foundation and it didn't work for me. When I use WebPartID as storageKey, I get the following message: The operation could not be completed because the Web Part is not on this page. –  Christophe Sep 22 '10 at 16:38
    
Try calling SaveWebPart() Web Service method and see if the return value matches the WebPartID attribute on the div. msdn.microsoft.com/en-us/library/ms774839(v=office.12).aspx –  Jaap Vossers Sep 22 '10 at 20:17
add comment

This Web Service has horrible documentation, even worse than the others. As I remember when I played around with it, I could get information about the Web Parts on the page with GetWebPartPage first.

share|improve this answer
add comment

You can send your web part ID to you javascript when the page is loaded.

Try

Guid ((Microsoft.SharePoint.WebPartPages.SPWebPartManager)WebPartManager).GetStorageKey(this);

As for saving your web part properties, instead of going through SOAP you could create a service that uses the SPLimitedWebPartManager using the storage key.

Something like this should work.

        using (SPWeb web = new SPSite(webUrl).OpwnWeb()){
    using (SPLimitedWebPartManager manager = GetLimitedWebPartManager(PublishingWeb.IsPublishingWeb(web) ? PublishingWeb.GetPublishingWeb.DefaultPage.Url : web.RootFolder.WelcomePage, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared))
    WebPart part = manager.WebParts[storageKey];
//Do web part stuff.
    }
    }
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.