3

I have created a SharePoint list. I have a situation to change the list name using c#.

please suggest any idea.

3
using (var oSite = new SPSite(fundURL))
{
      using (var oWeb = oSite.OpenWeb())
      {
          var listWithArticles = oWeb.Lists.TryGetList("Articles");

          if(listWithArticles != null)
          {
             listWithArticles.Title = "Exhibits";
             listWithArticles.Update();
          }
      }
}
0

You can try with Csom Code Below for changing the list name

ClientContext context=new ClientContext(SiteUrl);
List requiredlist=context.Web.Lists.GetByTitle("required list name");
context.Load(requiredlist);
context.ExecuteQuery();

requiredlist.Title="The New Name for the List";
requiredlist.Update();
context.ExecuteQuery();

if you want to change the Url of the List, use the below snippet

        ClientContext context=new ClientContext(SiteUrl);
        List list = context.Web.Lists.GetByTitle("List name");
        context.Load(context.Web);
        context.ExecuteQuery();
        context.Load(list.RootFolder);
        context.ExecuteQuery();
        list.RootFolder.MoveTo(context.Web.ServerRelativeUrl+"required Url");
        list.Update();
        context.ExecuteQuery();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.