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

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?

share|improve this question
    
Is this using SPLimitedWebPatManager, by any chance? –  James Love Jul 21 '12 at 7:23
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
I remember correctly specifying a non-existing zone name adds it to that zone anyways (thus storing it in a zone, that does not exist on the page). Had that issue a cpl of years back and we needed to add that "invisible" zone to the page so we could remove all the failed WPs. –  Wictor Wilen MCA MCM MVP Jul 21 '12 at 8:41
    
@Meyer Denney: You can find out the ID of the Zones in the pages by going to "Edit WebPart" section of any of the existing webparts on the page and looking in the "Layout" Section. –  Vardhaman Deshpande Jul 21 '12 at 18:26
    
Yes I went into the Layout section of Edit Web Part. The section was called "Full Page" and the zone index for the web part I installed was 3, sometimes 4, but in the code I have it set as 0. –  Meyer Denney Jul 21 '12 at 23:37
1  
Beware what you see in the Layout section is the Title of the WebPartZone and you need the ID. If you have the "Edit Web Part" open you can use IE Developer Tools (or view source) to see what is the value attribute of the <option> tag with content "Full Page". 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. –  Per Jakobsen Jul 22 '12 at 10:07
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.