views:

20

answers:

1

SharePoint newbie here.

I have a web part that is attached to SharePoint's edit page [EditForm.aspx]. How do I determine if the document being edited is linked to a content type that inherits, at any level of its inheritance chain, from a specified base type?

For instance, I have a base content type called "Document Base". I want this web part to take action if and only if the document being edited ultimately derives from this base type. How can I determine this from within my web part?

+2  A: 

Hi Seth

SPContentType wantedBase = web.ContentTypes["Document Base"];
if (listItem.ContentType.Id.IsChildOf(wantedBase.Id))
   // Yes this is a child
Per Jakobsen
Thanks for the quick reply! I see that `SPContext.Current` exposes the item being edited, and that knowledge combined with your answer are exactly what I needed.
Seth Petry-Johnson