Skip to main content

Posts

Showing posts from November, 2012

How to hide SharePoint List or Document Library

The requirement was to hide certain List or Document Library in a site. The following example shows how can it be done using object model.

I would like to bring out some points:
When a list is made hidden, it does not appear under "All Site Content" and Quick Launch".However, if user has created an explicit link to the list, it still appears.Also, if a user knows the URL, the hidden list can still be accessed.Item cannot be made hidden with this method. If the requirement is to block user from accessing the list, removing the permission is the ONLY way to achieve it.                     using (SPSite mySite = new SPSite("Site URL"))
                    {
                        using (SPWeb myWeb = mySite.OpenWeb())
                        {
                            bool hidden = true;
                            myWeb.AllowUnsafeUpdates = true;
                            SPList lst = myWeb.Lists["List Name"];
                            lst.Hidden = h…