Peter Schneider


MCT, MCSD.NET, MCAD.NET, MCDBA

News

Locations of visitors to this page

  

Austrian .NET Community

Sharepoint ListTemplateId

If you want to add a Event Handler Assembly to a specific list in Sharepoint with a Feature you have to pass a ListTemplateId.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers ListTemplateId="104">
<Receiver>
<Name>EventHandler Delete</Name>
<Type>ItemDeleting</Type>


Here's a little codesnippet to get those ListTemplateIds, just add a Reference to Microsoft.Sharepoint.dll.

string[] typeNames = System.Enum.GetNames(typeof(SPListTemplateType));
Array typeValues = System.Enum.GetValues(typeof(SPListTemplateType));

int j = 0;

foreach (int i in typeValues)
{
Console.WriteLine(typeNames[j++].ToString() + " " + i.ToString ());
}


The output of the codesnippet above should look something like this:

GenericList 100
DocumentLibrary 101
Survey 102
Links 103
Announcements 104
Contacts 105
Events 106
Tasks 107
DiscussionBoard 108
PictureLibrary 109

Actually these ListTemplateIds (Types) are part of the ListTemplate definitions you can find in ONET.XML

Posted: Nov 22 2006, 07:06 PM by pschneider | with 8 comment(s)
Filed under:

Comments

Fabiano Fran??a » Blog Archive » links for 2007-07-04 said:

Pingback from  Fabiano Fran??a  &raquo; Blog Archive   &raquo; links for 2007-07-04

# July 4, 2007 4:29 AM

øystein said:

Nice to know! :-)

Now, all lists with the templateid will be influenced. Is it possible to use a specific list on the site instead of listtemplates?

# July 26, 2007 8:34 AM

Carlos Ligues said:

Here is the list:

GenericList 100

DocumentLibrary 101

Survey 102

Links 103

Announcements 104

Contacts 105

Events 106

Tasks 107

DiscussionBoard 108

PictureLibrary 109

DataSources 110

WebTemplateCatalog 111

UserInformation 112

WebPartCatalog 113

ListTemplateCatalog 114

XMLForm 115

MasterPageCatalog 116

NoCodeWorkflows 117

WorkflowProcess 118

WebPageLibrary 119

CustomGrid 120

DataConnectionLibrary 130

WorkflowHistory 140

GanttTasks 150

Meetings 200

Agenda 201

MeetingUser 202

Decision 204

MeetingObjective 207

TextBox 210

ThingsToBring 211

HomePageLibrary 212

Posts 301

Comments 302

Categories 303

IssueTracking 1100

AdminTasks 1200

# July 31, 2007 4:48 PM

Rick Mason said:

That's not the whole list - it can have values other than those in the SPListTemplateType enum.

The Pages list used in WCM is 850. Without an enum value to check against, I found this the only way to check its value:

if (Int32.Parse(theList.BaseTemplate.ToString(CultureInfo.InvariantCulture)) == 850)

# August 8, 2007 5:10 AM

N@poleone said:

Hi,

I'm trying to code an event handler for the itemadded event only for a Task list, so with id = 107. I put Receivers ListTemplateId="107" in the elements.xml of the feature, but the event is trapped also when I add some item in a doclib list... Do you know why?

# November 29, 2007 12:19 PM

Raymond Mitchell said:

If you've started playing with Features in SharePoint 2007, you've probably run across a few places where

# January 4, 2008 2:16 PM

David said:

How do I trap when someone creates a Page?  I tried 119, but that does not work.  I have a News site and I want to trap when someone adds an article.

# February 27, 2008 1:29 PM

Raxi said:

some times event handlers doesnt seems to work. so u need to resed iis(iisreset) and it ll eventually work.

# June 22, 2008 1:26 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)