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

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

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted
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;
        }
    }
}
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.