Monday, August 11, 2008

Web part import - zoneIndex doesn't work

If you have ever tried to import web parts using SPLimitedWebPartManager AddWebPart you'll notice the zoneIndex parameter.

Unfortunately it turns out that zoneIndex only works if web parts are imported in sequence - so you'll need to make certain import is done in the proper sequence order.

After import zoneIndex cannot be modified programmatically - at least I've not found a way to do this.

2 comments:

Anonymous said...

SPLimitedWebPartManager.MoveWebPart()

Gaurav said...

ZoneIndex works as expected in the call to the AddWebPart method. If for some reason it isn't working for you, make sure you are passing the correct ZoneID and ZoneIndex. No error is thrown if any of these parameters are incorrect and the webpart is added to the end.

For example, the Zone Id for the "Right" Zone is actually "RightColumn". Passing "Right" as the ZoneId instead of "RightColumn" will cause the webpart to be added to an incorrect zone/ zoneindex.