Online Training On SharePoint
                      

Sunday 2 November 2008

Hiding Site Collection Documents and Site Collection Images Libraries In SharePoint

Recently we got a requirment where we either need to hide/delete "Site Collection Documents", "Site Collection Images" Libraries from the viewlsts.aspx page. Users should not be able to access these libraries from this page.
While trying to delete these sites we realised that delete option for these libraries is not visible from the GUI. When we attempted to delete with the SharePoint Designe we got the error:
“Server Error: The folder selected for deletion contains one or more lists, document libraries, or galleries that your web site requires in order to function correctly. Therefore, you cannot delete the folder.” So there was no easy way for us to delete these libraries.
Then we started trying to hide these libraries. Hiding of these libraries is possible with SPList.Hidden property in the SharePoint user interface. Following is the code snippet with which the libraries were hided:

SPSite site = new SPSite(http://localhost/);
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Site Collection Documents"];
list.Hidden = true;
list.Update();
list = web.Lists["Site Collection Images"];
list.Hidden = true;
list.Update();

3 comments:

MAK said...

HI manish,

I just added your code and it works awsome.My question is if i want to revert it back what should i do.I mean If i want to make it visible.
as
list.visible = true;

is not working.
Your response will be highly appreciated.

Anonymous said...

Have you tried list.hidden = False?

Unknown said...

You can also use SharePoint Designer to hide the libraries:

1. Right-click on the Library in the SPD Folder List, and select Properties

2. Go to the Settings tab and check the "Hide from Browsers" box

That's it! Now the Library is still on the system, but doesn't show up in the IE browser.

Hope that helps...

Related Posts with Thumbnails