Friday, March 4, 2011

Creating a document library in Sharepoint through code.


Recently there was a requirement to create a document library in Sharepoint from an ASP.NET page. I used the following code to achive this:
1. Add a reference to the sharepoint list service web service.
2. I then used the List webservice to create the document library using the code below
Web_Reference_Folder.Lists listService = new Web_Reference_Folder.Lists();
listService.Credentials = new System.Net.NetworkCredential("username", "password");
XmlNode ndList = listService.AddList("document library name", "Type any description for your document library", 101);
"101" in the above code is used to create a document library.
Thats it! :)
 –Srihari.

No comments:

Post a Comment