I'm having a problem accessing ContentEditorWebparts on a page through
C# code. My code is as follows:
SPLimitedWebPartManager webPartManager =
listItem.File.GetLimitedWebPartManager(PersonalizationScope.Shared);
SPLimitedWebPartCollection webParts= webPartManager.WebParts;
foreach (Microsoft.SharePoint.WebPartPages.WebPart webPart in webParts)
{
ContentEditorWebPart contentEditorWebPart = webPart as
ContentEditorWebPart;
if (contentEditorWebPart != null)
{
//doesn't get here
}
else
{
Console.WriteLine(webPart.GetType().FullName)
}
}
This code outputs 'Microsoft.SharePoint.WebPartPages.ErrorWebPart' each
time.
If I view the page using '?contents=1' all the WebParts are listed as
'ContentEditorWebPart'
I'm using MOSS 2007.
Anyone have any ideas what's going wrong?
Thanks,
Ken