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

Preface: I did not come up with this implementation, just dealing with it.

I have a web part zone that gets 3 content editor web parts loaded into it dynamically through the feature receiver. The content parts are created on the page, exported to XML, the XML exports are added to the VS project, and then deleted from the page to be added through the receiver to an aspx page with zones defined. An SPLimitedWebPartManager is used in the FeatureActivated event and calls AddWebPart() for each content part to be added (the XML files).

The problem is the order that they are displayed on the page. The sequence of adding them in the receiver is correct, and the only order property I can discern in the XML is PartOrder which are currently set to 1,2, and 10. They should display in that order but the second one is always last on the final page.

I've tried deleting/recreating the site collection and they still always appear in the wrong order.

Any idea on how to get them to be added to the page in the proper order?

Thanks.

share|improve this question
add comment

2 Answers

Can you debug the feature receiver and look at the parameters being passed to AddWebPart()? Make sure the zoneId value is correct, e.g. "RightColumn" and that the zoneIndex looks right. Are you sure that PartOrder is the value passed in as zoneIndex? It is suspicious that the order is 1, 10, 2, since that is sorted alphabetically; maybe the code that reads the XML is sorting string values instead of converting to a number first.

share|improve this answer
add comment

You should try to use the ZoneIndex property (attribute) instead of the PartOrder. PartOrder is obsolete since WSS 3.0. PartOrder can lead to some confusion because the WebPart base class (System.Web.UI.WebControls.WebParts.WebPart) does not have this property. But that should not be the problem in your case because you are adding three web parts of the same type (is that correct?).

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.