Creating keyword in site




Go back to index

How to create keyword in Site Collection


Following code block explains how to programmatically create keyword in Site Collection.

      using System;
      using SPTool.Library;
      using System.Collections;
      
      namespace SPTool.Test
      {
          class Program
          {
              static void Main(string[] args)
              {
                  SPTSite site = new SPTSite("http://sptool/");
                  
                  // Create keyword
                  SPTReturn returnObj = site.CreateKeyword("TestKeyword", new string[] { "Test", "Keyword" }, null, "", Constants.AdminUser, DateTime.Today,DateTime.Today.AddDays(10), DateTime.Today.AddDays(5));
                              
                  // Check the status of creating keyword
                  if (returnObj.State == SPTState.Success)
                  {
                      // Creating keyword successful
                  }
                  else
                  {
                      // Creating keyword failed
                  }
                  return returnObj;
              }
          }
      }
      


Go back to index