1

How to find the ZoneID of a list view webpart remotely?

  • We can use any means to get the information; CSOM, JSON, web services or hacks. But we cannot use server-side code.

  • We can know any information of the web part beforehand except the ZoneID

For example: We know the Id of a list view webpart, and we know the page where it is. Now we need to know its ZoneID...

Challenges:

  • CSOM doesn't allow us to get ZoneID from WebPartDefinition
  • Web services do, but list view webparts do not allow export of properties (Id or ZoneID), so we cannot use WebPartPages.asmx and GetWebPartProperties2 for list view web parts (?)

1 Answer 1

1

I know this is an old question but I have been struggling with the same problem and I thought I should add the solution I have come up with for future searches.

Zone ID doesn't seem to be exposed for most web parts, specifically the ones using xmlns="http://schemas.microsoft.com/WebPart/v3" (where all properties are returned as "property" elements).

If your web part happens to be using xmlns="http://schemas.microsoft.com/WebPart/v2" (where properties are returned as elements on their own) then Zone ID will be one of the XML elements returned as part of the web part definition when you use the SharePoint web service GetWebPart2 or GetWebPartProperties2.

For the web parts where you don't get the Zone ID your only option left is getting the page contents using GetWebPartPage web service and parsing it.

Within the page you'll have the web part elements within "WebPartPages:WebPartZone" elements (each representing a different zone).

These web part elements have the ID of the web part as well as the ZoneID within their main XML node. So you can use regex to fish it out.

Here is a very simple regex (make sure you set the case-insensitive option on whatever environment you're running this on):

ZoneID="(.\*?)".\*?0a32c6f6-ee05-4c8e-ba7a-587c0c67c382

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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