Term Store Manangement

How to access SharePoint Site Term Store Management?

Go to SharePoint Site, then Site Settings and select Term Store Management.

Term Store Management

Term Store Management Concept

Term Store Management Concept

SharePoint APP Model

Step 1: Add Permission in AppManifest.xml file to read Taxonomy as follows.

permissions

Step 2: User Interface Design Page.

Taxonomy.aspx

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Texonomy.aspx.cs" Inherits="SP_TexonomyProWeb.Pages.Texonomy" %>
  2. <!DOCTYPE html>
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head runat="server">
  5. <title></title>
  6. </head>
  7. <body>
  8. <form id="form1" runat="server">
  9. <div>
  10. <table>
  11. <tr>
  12. <td>
  13. <asp:Label ID="Label1" runat="server" Text="Region"></asp:Label></td>
  14. <td>
  15. <asp:DropDownList ID="ddlDepartment" runat="server"></asp:DropDownList></td>
  16. </tr>
  17. <tr>
  18. <td colspan="2"> </td>
  19. </tr>
  20. <tr>
  21. <td>
  22. <asp:Label ID="Label2" runat="server" Text="Division"></asp:Label></td>
  23. <td>
  24. <asp:DropDownList ID="ddlJobTitle" runat="server"></asp:DropDownList></td>
  25. </tr>
  26. </table>
  27. </div>
  28. </form>
  29. </body>
  30. </html>
Taxonomy.aspx.cs
  1. using Microsoft.SharePoint.Client.Taxonomy;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. namespace SP_TexonomyProWeb.Pages
  10. {
  11. public partial class Texonomy : System.Web.UI.Page
  12. {
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. string TermStoreName = "Managed Metadata Service";
  16. string TermGroupName = "Texo";
  17. BindTermstoDropdown(TermStoreName, TermGroupName, "Region", ddlDepartment);
  18. BindTermstoDropdown(TermStoreName, TermGroupName, "Categories", ddlJobTitle);
  19. }
  20. protected void BindTermstoDropdown(string TermStoreName, string TermGroupName, string TermSetName, DropDownList ddl)
  21. {
  22. var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
  23. using (var clientContext = spContext.CreateUserClientContextForSPHost())
  24. {
  25. clientContext.Load(clientContext.Web, web => web.Title);
  26. clientContext.ExecuteQuery();
  27. Response.Write(clientContext.Web.Title);
  28. // Get the TaxonomySession
  29. TaxonomySession taxonomySession = TaxonomySession.GetTaxonomySession(clientContext);
  30. // Get the term store by name
  31. TermStore termStore = taxonomySession.TermStores.GetByName(TermStoreName);
  32. // Get the term group by Name
  33. TermGroup termGroup = termStore.Groups.GetByName(TermGroupName);
  34. // Get the term set by Name
  35. TermSet termSet = termGroup.TermSets.GetByName(TermSetName);
  36. // Get all the terms
  37. TermCollection termColl = termSet.Terms;
  38. clientContext.Load(termColl);
  39. // Execute the query to the server
  40. clientContext.ExecuteQuery();
  41. // Loop through all the terms
  42. DataTable dt = new DataTable();
  43. dt.Columns.Add("TermName");
  44. DataRow row = null;
  45. foreach (Term term in termColl)
  46. {
  47. row = dt.NewRow();
  48. row["TermName"] = term.Name;
  49. dt.Rows.Add(row);
  50. }
  51. ddl.DataSource = dt;
  52. ddl.DataTextField = "TermName";
  53. ddl.DataValueField = "TermName";
  54. ddl.DataBind();
  55. }
  56. }
  57. }
  58. }
Output:

Output

Thank you! If you have any query, then please mention it in the comment section.