I am adding a web part using the following code and xml:
string xemelek = "<?xml version='1.0' encoding=\"utf-8\"?><webParts><webPart xmlns='http://schemas.microsoft.com/WebPart/v3'><metaData><type name='Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' /><importErrorMessage>Cannot import this Web Part.</importErrorMessage></metaData><data><properties><property name='ListUrl' type='string' /><property name='ListId' type='System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'>757981FB-184A-441B-952D-9434BE33DC85</property><property name='ListName' type='string'>{757981FB-184A-441B-952D-9434BE33DC85}</property></properties></data></webPart></webParts>";
WebPartDefinition newWebiie = wpm.ImportWebPart(xemelek2);
WebPartDefinition webpartie = wpm.AddWebPart(newWebiie.WebPart, "ms-comm-homeWelcome ms-core-defaultFont", 0);
ctx.Load(newWebiie);
ctx.ExecuteQuery();
Whatever zoneId I use, the webpart always lands at the bottom of the page:
Inspect element shows the following zones:
What I tried so far:
- "Rich Content" - adds but at the bottom
- "ms-rte-layoutszone-outer" - adds but at the bottom
- "ms-rte-layoutszone-inner-editable ms-rtestate-write" - adds but at the bottom
- "mainContent" - adds at the bottom
- "wpz" - copied from a post on Wiki Page, did not work, no surprise
- "Zone 2", Index 0 and 3 - adds at the bottom
- "Top", Index 0 and 10 - adds at the bottom
I have set ZoneIndex to 0 and this is the only web part in this zone, but this seems to have no effect.
How can I set the web part to be just under the page title like this?:
Settings from a manually added web part:
The same behaviour can be observed on multiple pages and several sites (all that I tested).