5

In a feature I need to check if a part is already on the page.

How can this be performed (programatically) (i.e. through a feature)

thx

9
SPLimitedWebPartManager manager = web.GetLimitedWebPartManager("default.aspx", PersonalizationScope.Shared);
if (manager != null)
{
    foreach (Microsoft.SharePoint.WebPartPages.WebPart webpart in manager.WebParts)
    {
        if (webpart.Title == "some title")
        {
            // Web Part found!

            break;
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.