I want to Create List Definition & List Instance under particular Sub-site.It can not been seen under site Collection.


Create your List Definition using a Web Scoped feature. Set the feature attributes to Hidden=True.

You can then activate your feature manually using PowerShell for that sub-site.

For further automation you can either staple your feature to specific templates (so it is automatically included in sites which uses a specific template) or reference it in the WebFeatures element in the Onet.xml of your custom site definition.


Accomplished with the following code in Feature Activated event receiver.

SPSite site = null;
SPWeb web = null;
site = properties.Feature.Parent as SPSite;
web = site.AllWebs["SubSite"];
SPListTemplate temp = web.ListTemplates["ListDefinition"];
Guid newg = web.Lists.Add("ListInstance", "Description", temp);
SPList newlist = web.Lists[newg];
newlist.OnQuickLaunch = true;
  • This will make List Named listInstance on Custom ListDefinition named listDefinition. Jun 12 '13 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.