Hi,
I don't think there is an Event dedicated to a list creation.
What you can do :
- Create an Application Page where users can enter the type of the List (Doc Lib, Announcements, ...) and the wanted name.
- Create a Custom Action to add a link to this page in the Site Collection Settings
- Use a recursive method to add the Library to each sites
You can also
- Create a WebPart which will create the doc lib on each sites
I created this sample code from an Console Application ... it's seems to work.
static void Main(string[] args)
{
using (SPSite siteColl = new SPSite("http://srvsp2013/"))
{
CreateDocLib("Selected Doc Lib", siteColl.RootWeb);
}
}
static void CreateDocLib(string docLibName, SPWeb currentWeb)
{
currentWeb.Lists.Add(docLibName, "Created by code Doc Lib", SPListTemplateType.DocumentLibrary);
foreach (SPWeb subweb in currentWeb.Webs)
{
CreateDocLib(docLibName, subweb);
}
}
Best Regards,
Frederic
Please remember to click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if it was useful.
No comments:
Post a Comment