Question

I am installing a web part on a few different pages. I have set my zone index to 0, yet they still wind up below the other web parts on the page. Here is my code:

        TasksWebPart intakeTasksWebPart = new WebPart();
        intakeTasksWebPart.Title = "Tasks Web Part";
        intakeTasksWebPart.ChromeState = System.Web.UI.WebControls.WebParts.PartChromeState.Normal;
        intakeTasksWebPart.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.TitleAndBorder;
        webPartManager.AddWebPart(intakeTasksWebPart, "Full Page", 0);
        web.Update();

There are no other web part zones that I can see on the page other then Full Page. There is already a web part on the page before my code tries to add this web part. When I open the page, my web part will be at the bottom and have a zone index of 2 or 3.

Any thoughts?

Was it helpful?

Solution

Make sure you're using the ID of the zone (which usually doesn't contain space) and not the Display title which is shown in the UI.

If you specify a non existing ID SharePoint may add your web part to the last zone on the page, but doesn't care about the Index

If you search view source of the page in edit mode (with web part zone showing) for zoneTitle="Full Page" you find a table the zoneID attribute is what you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top