Skip to main content
added 59 characters in body
Source Link
Ali Jafer
  • 17.8k
  • 1
  • 28
  • 41

You can simply do it by doing:

Gets a value that specifies the content type of the list item.

Returns a ContentType.instance representing the content type of the list item.

SPContentType = properties.ListItem.ContentType;

so for item adding it will be:

public override void ItemAdding(SPItemEventProperties properties)
{
    SPContentType ct = properties.ListItem.ContentType;
}

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.listitem.contenttype.aspx

Just for clarification for item added event for others:

In the item added event its slightly different

public override void ItemAdded(SPItemEventProperties properties)
{
    
    SPList list = properties.listName;  

    string ctName = properties.AfterProperties["ContentType"].ToString();  

    SPContentType contentType = list.ContentTypes[ctName]; 

}

hope it helps :)

You can simply do it by doing:

Gets a value that specifies the content type of the list item.

Returns a ContentType.instance representing the content type of the list item.

SPContentType = properties.ListItem.ContentType;

so for item adding it will be:

public override void ItemAdding(SPItemEventProperties properties)
{
    SPContentType ct = properties.ListItem.ContentType;
}

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.listitem.contenttype.aspx

In the item added event its slightly different

public override void ItemAdded(SPItemEventProperties properties)
{
    
    SPList list = properties.listName;  

    string ctName = properties.AfterProperties["ContentType"].ToString();  

    SPContentType contentType = list.ContentTypes[ctName]; 

}

hope it helps :)

You can simply do it by doing:

Gets a value that specifies the content type of the list item.

Returns a ContentType.instance representing the content type of the list item.

SPContentType = properties.ListItem.ContentType;

so for item adding it will be:

public override void ItemAdding(SPItemEventProperties properties)
{
    SPContentType ct = properties.ListItem.ContentType;
}

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.listitem.contenttype.aspx

Just for clarification for item added event for others:

In the item added event its slightly different

public override void ItemAdded(SPItemEventProperties properties)
{
    
    SPList list = properties.listName;  

    string ctName = properties.AfterProperties["ContentType"].ToString();  

    SPContentType contentType = list.ContentTypes[ctName]; 

}

hope it helps :)

Source Link
Ali Jafer
  • 17.8k
  • 1
  • 28
  • 41

You can simply do it by doing:

Gets a value that specifies the content type of the list item.

Returns a ContentType.instance representing the content type of the list item.

SPContentType = properties.ListItem.ContentType;

so for item adding it will be:

public override void ItemAdding(SPItemEventProperties properties)
{
    SPContentType ct = properties.ListItem.ContentType;
}

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.listitem.contenttype.aspx

In the item added event its slightly different

public override void ItemAdded(SPItemEventProperties properties)
{
    
    SPList list = properties.listName;  

    string ctName = properties.AfterProperties["ContentType"].ToString();  

    SPContentType contentType = list.ContentTypes[ctName]; 

}

hope it helps :)