Wednesday, September 17, 2008

Programatically deleting an Audience from Audience Collection

Code:

using (SPSite spSite = new SPSite(@"http://localhost"))
{
ServerContext siteContext = ServerContext.GetContext(spSite);
AudienceManager amManager = new AudienceManager(siteContext);

string strName = "Technology Department";

if (amManager.Audiences.AudienceExist(strName))
{
amManager.Audiences.Remove(strName);
}
}

0 comments: