I put a web part on a page through a feature.

I deactivate the feature.

Then when I go to activate it again, i loop through the wpManager.WebParts to determine if it is already on the page

using (SPLimitedWebPartManager wpManager = site.GetLimitedWebPartManager(url + page, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared)) {
      try {
         SPLimitedWebPartCollection existingParts = wpManager.WebParts;

         //I loop through checking to see if it is on the page) here

If I manually activate/deactivate it all works fine. The problem occurs when I activate the feature from another feature. Yes, I have one feature that acts as a wrapper which then activates other features in a particular order. Well, when activating this wrapper and doing the loop above the existingParts.Count = 0

I cannot explain this behavior. Ideas?

  • Can you give us some more details about for instance your "wrapper" works (and looks like in code)? Commented Sep 26, 2010 at 8:33
  • What scope is this other Feature?
    – James Love
    Commented Jul 28, 2011 at 10:15
  • @dave check the properties, I don't think they are coming through as expected to the child feature, wrong scope is the most likely scenario as James Love suggested.
    – Hugh Wood
    Commented Nov 13, 2012 at 17:20
  • 1
    This question appears to be off-topic because it is older than three months, the poster of the question hasn't been seen for three months and it contains no answers or no upvoted answers. (see meta.sharepoint.stackexchange.com/questions/1014/…)
    – SPArcheon
    Commented Jan 17, 2014 at 8:45


Browse other questions tagged or ask your own question.