SharePoint - Display post title based on enterprise keyword in sharepoint 2010

Asked By Lavanya on 02-Aug-11 02:16 AM
Hi

 I have got requirement in sharepoint 2010.I am displaying enterprise keyword on my custom page  based on displayed enterprise keyword. I need to fetch corresponding post title matching enterprise keyword how to go about it.After doing research on couple of sites i found search.asmx can be used for this but search.asmx accepts only 1 parameter but my post can have multiple enterprise keyword
TSN ... replied to Lavanya on 02-Aug-11 02:19 AM
hi..

To enable enterprise keywords using object model do the following steps:
  • Open Visual Studio 2010. 

  • Go to File => New => Project. 

  • Select Console Application template from the installed templates. 

  • Add the following references.

    Microsoft.SharePoint 

  • Add the following namespaces.

    using Microsoft.SharePoint;

  • Replace Program.cs with the following code.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint;
    namespace EnterpriseKeywords
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (SPSite site = new SPSite("http://serverName:22222/sites/Test/"))
                {
                    using (SPWeb web = site.OpenWeb("BL"))
                    {
                        SPList list = web.Lists.TryGetList("dl");
                        if (list != null)
                {
                            SPField field = list.ParentWeb.AvailableFields["Enterprise Keywords"];
                            if (!list.Fields.ContainsField("Enterprise Keywords"))
                            {
                                list.Fields.Add(field);
                                list.Update();
                                Console.WriteLine(field.Title + " added successfully to the list");
                            }
                            else
                            {
                        Console.WriteLine(field.Title + " column already exists in the list");
                            }
                        }
                        else
                        {
                            Console.WriteLine(list.Title + " does not exists in the site");
                        }
                        Console.ReadLine();
                    }
                }
            }
        }
    }

  • Build the solution.

  • Hit F5.

  • Go to the =>Permissions and Management => Enterprise Metadata and Keywords Settings.

  • You could see the "Enterprise Keywords" enabled.
Asked By Lavanya on 02-Aug-11 02:22 AM
Thanks for your reply.I guess you are using custom c# code but i am restricted to use custom c# code.Further more "conditional formatting " is used only to style data
Jitendra Faye replied to Lavanya on 02-Aug-11 02:31 AM
Enterprise keywords are used to tag the documents when uploading the documents in the document library. Enterprise documents can be enabled in both SharePoint lists and libraries. Enterprise keywords - Terms are stored in a non-hierarchical way and available for users to key in which is known as folksonomy (free tagging). In this article we will be seeing how to enable Enterprise keywords for a list using SharePoint object model.

Prerequisites:
  1. Managed metadata service application should be configured. 

  2. Web application should be associated to the Managed Metadata Service Application.
Programmatically Enable Enterprise Keywords:

To enable Enterprise keywords through UI refer http://www.c-sharpcorner.com/UploadFile/anavijai/7633.

To enable enterprise keywords using object model do the following steps:
  • Open Visual Studio 2010. 

  • Go to File => New => Project. 

  • Select Console Application template from the installed templates. 

  • Add the following references.

    Microsoft.SharePoint 

  • Add the following namespaces.

    using Microsoft.SharePoint;

  • Replace Program.cs with the following code.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint;
    namespace EnterpriseKeywords
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (SPSite site = new SPSite("http://serverName:22222/sites/Test/"))
                {
                    using (SPWeb web = site.OpenWeb("BL"))
                    {
                        SPList list = web.Lists.TryGetList("dl");
                        if (list != null)
              {
                            SPField field = list.ParentWeb.AvailableFields["Enterprise Keywords"];
                            if (!list.Fields.ContainsField("Enterprise Keywords"))
                            {
                                list.Fields.Add(field);
                                list.Update();
                                Console.WriteLine(field.Title + " added successfully to the list");
                            }
                            else
                            {
                        Console.WriteLine(field.Title + " column already exists in the list");
                            }
                        }
                        else
                        {
                            Console.WriteLine(list.Title + " does not exists in the site");
                        }
                        Console.ReadLine();
                    }
                }
            }
        }
    }

  • Build the solution.

  • Hit F5.

  • Go to the =>Permissions and Management => Enterprise Metadata and Keywords Settings.

Follow this link-

http://www.c-sharpcorner.com/UploadFile/anavijai/7670/

  • You could see the "Enterprise Keywords" enabled.
Jitendra Faye replied to Lavanya on 02-Aug-11 02:31 AM
Enterprise keywords are used to tag the documents when uploading the documents in the document library. Enterprise documents can be enabled in both SharePoint lists and libraries. Enterprise keywords - Terms are stored in a non-hierarchical way and available for users to key in which is known as folksonomy (free tagging). In this article we will be seeing how to enable Enterprise keywords for a list using SharePoint object model.

Prerequisites:
  1. Managed metadata service application should be configured. 

  2. Web application should be associated to the Managed Metadata Service Application.
Programmatically Enable Enterprise Keywords:

To enable Enterprise keywords through UI refer http://www.c-sharpcorner.com/UploadFile/anavijai/7633.

To enable enterprise keywords using object model do the following steps:
  • Open Visual Studio 2010. 

  • Go to File => New => Project. 

  • Select Console Application template from the installed templates. 

  • Add the following references.

    Microsoft.SharePoint 

  • Add the following namespaces.

    using Microsoft.SharePoint;

  • Replace Program.cs with the following code.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint;
    namespace EnterpriseKeywords
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (SPSite site = new SPSite("http://serverName:22222/sites/Test/"))
                {
                    using (SPWeb web = site.OpenWeb("BL"))
                    {
                        SPList list = web.Lists.TryGetList("dl");
                        if (list != null)
              {
                            SPField field = list.ParentWeb.AvailableFields["Enterprise Keywords"];
                            if (!list.Fields.ContainsField("Enterprise Keywords"))
                            {
                                list.Fields.Add(field);
                                list.Update();
                                Console.WriteLine(field.Title + " added successfully to the list");
                            }
                            else
                            {
                        Console.WriteLine(field.Title + " column already exists in the list");
                            }
                        }
                        else
                        {
                            Console.WriteLine(list.Title + " does not exists in the site");
                        }
                        Console.ReadLine();
                    }
                }
            }
        }
    }

  • Build the solution.

  • Hit F5.

  • Go to the =>Permissions and Management => Enterprise Metadata and Keywords Settings.

Follow this link-

http://www.c-sharpcorner.com/UploadFile/anavijai/7670/

  • You could see the "Enterprise Keywords" enabled.