3

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)? – Wictor Wilen MCA MCM MVP Sep 26 '10 at 8:33
  • What scope is this other Feature? – James Love Jul 28 '11 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 Nov 13 '12 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/…) – Hitodama Jan 17 '14 at 8:45

Browse other questions tagged or ask your own question.