How to Display/hide list in Quick Launch option in the website using CSOM

Hi All,

In this example you will see how to display or hide list in the Quick Launch bar. When you are creating a new custom list at that time you will see list on quick launch bar by default. Here you can hide/show list in the Quick Launch bar. based on your requirement using CSOM.

Below code snippet shows complete view.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
using System.Security;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            ClientContext clientContext = new ClientContext("Your SharePoint Site");

            var passWord = new SecureString();

            foreach (char c in "password".ToCharArray()) passWord.AppendChar(c);

            // Authentication-with-sharepoint-online-and-the-client-side-object-model

            clientContext.Credentials = new SharePointOnlineCredentials("Yoursitename.onmicrosoft.com", passWord);

            ListCreationInformation olistcreation = new ListCreationInformation();

            olistcreation.QuickLaunchOption = QuickLaunchOptions.Off; // Will not show list in Quick launch option
            olistcreation.QuickLaunchOption = QuickLaunchOptions.On;  // Will show list in Quick launch option         
             olistcreation.Title = "Name";

            olistcreation.Description = "New Branch";

            olistcreation.TemplateType = (int)ListTemplateType.GenericList;

             // Create a new custom list 
            List olist = clientContext.Web.Lists.Add(olistcreation);

             // Retrieve the custom list properties
            clientContext.Load(olist);

            //Execute the query
            clientContext.ExecuteQuery();
        }
    }

}
पुढे
« Prev Post
Previous
Next Post »