TaxonomyFieldControl - Classe

Fournit l'expérience de modification pour un objet TaxonomyField .

Hiérarchie d’héritage

System.Object
  System.Web.UI.Control
    Microsoft.SharePoint.WebControls.SPControl
      Microsoft.SharePoint.WebControls.TemplateBasedControl
        Microsoft.SharePoint.WebControls.FormComponent
          Microsoft.SharePoint.WebControls.FieldMetadata
            Microsoft.SharePoint.WebControls.BaseFieldControl
              Microsoft.SharePoint.Taxonomy.TaxonomyFieldControl

Espace de noms :  Microsoft.SharePoint.Taxonomy
Assembly :  Microsoft.SharePoint.Taxonomy (dans Microsoft.SharePoint.Taxonomy.dll)

Syntaxe

'Déclaration
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class TaxonomyFieldControl _
    Inherits BaseFieldControl
'Utilisation
Dim instance As TaxonomyFieldControl
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class TaxonomyFieldControl : BaseFieldControl

Remarques

Le contrôle de champ de taxonomie contient une classification contrôle de balises Web. Il s'agit d'initialiser une nouvelle instance du site Web contrôle avec toutes les propriétés de l'objet TaxonomyField de repérage des reponsiblefor. Elle initialise également la contrôle de balises Web avec sa valeur initiale de taxonomie et met ensuite à jour l'objet TaxonomyField avec la valeur sélectionnée après modification.

Exemples

using System;
using System.IO;
using System.Globalization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Taxonomy;

// To build this file, create a Console project and add the following .NET assembly references:
// Microsoft.SharePoint
// Microsoft.SharePoint.Taxonomy

namespace Microsoft.SDK.SharePoint.Taxonomy.Samples
{
    public class TestTaxonomyFieldControl
    {
        private void TestGetTaxonomyCollection()
        {
            // These test strings contain label-path pairs:
            // input1 contains a single label-path pair (a path is a sequence of 1 or more GUIDs)
            // input2 contains two label-path pairs
            string input1 = "label1|B5EE7261-FD7C-47D2-9DB9-D499640EED01|BA3EBBB7-9C3E-414C-9625-8BCE5F422818";
            string input2 = "label2|E87A3A52-365A-4E6B-8F37-F6DCED9F8EDD;label3|1CCB014A-5647-493F-B366-6D9F99FD7894";
            
            Console.WriteLine("input1 = {0}", input1);
            Console.WriteLine("input2 = {0}", input2);

            // Parse the test string for a single taxonomy field value
            TaxonomyFieldValue taxValue1 = TaxonomyFieldControl.GetTaxonomyValue(input1);

            // Prints:
            //      label1 - BA3EBBB7-9C3E-414C-9625-8BCE5F422818
            Console.WriteLine("\nGetTaxonomyValue(input1):");
            Console.WriteLine("{0} - {1}", taxValue1.Label, taxValue1.TermGuid);
            
            // Parse the test string for a taxonomy field value collection
            TaxonomyFieldValueCollection taxFieldValueCollection1 = TaxonomyFieldControl.GetTaxonomyCollection(input1);
            TaxonomyFieldValueCollection taxFieldValueCollection2 = TaxonomyFieldControl.GetTaxonomyCollection(input2);

            // Prints:
            //      label1 - BA3EBBB7-9C3E-414C-9625-8BCE5F422818
            Console.WriteLine("\nGetTaxonomyCollection(input1):");
            foreach (TaxonomyFieldValue fv in taxFieldValueCollection1)
            {
                Console.WriteLine("{0} - {1}", fv.Label, fv.TermGuid);
            }

            // Prints:
            //      label2 - E87A3A52-365A-4E6B-8F37-F6DCED9F8EDD
            //      label3 - 1CCB014A-5647-493F-B366-6D9F99FD7894
            Console.WriteLine("\nGetTaxonomyCollection(input2):");
            foreach (TaxonomyFieldValue fv in taxFieldValueCollection2)
            {
                Console.WriteLine("{0} - {1}", fv.Label, fv.TermGuid);
            }

            // Convert the field value collections back into a string representation
            string output1 = TaxonomyFieldControl.GetMultipleValueText(taxFieldValueCollection1);
            string output2 = TaxonomyFieldControl.GetMultipleValueText(taxFieldValueCollection2);

            // Prints:
            //      label1|BA3EBBB7-9C3E-414C-9625-8BCE5F422818
            //      label2|E87A3A52-365A-4E6B-8F37-F6DCED9F8EDD;label3|1CCB014A-5647-493F-B366-6D9F99FD7894
            Console.WriteLine("\nString representations:");
            Console.WriteLine(output1);
            Console.WriteLine(output2);
        }
    }
}

using System;
using System.IO;
using System.Globalization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Taxonomy;

// To build this file, add the following .NET assembly references to the project:
// System.Web
// Microsoft.SharePoint
// Microsoft.SharePoint.Taxonomy

namespace Microsoft.SDK.SharePoint.Taxonomy.Samples
{
    public class TestTaxonomyFieldControlOnPage : System.Web.UI.Page
    {
        // Use the following declaration to place the TaxonomyFieldControl on a custom layouts ASPX page:
        // <Taxonomy:TaxonomyFieldControl id="myTaxonomyFieldControl" ControlMode="display" runat="server" />
        protected TaxonomyFieldControl myTaxonomyFieldControl;

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (!IsPostBack)
            {
                // Assume we have a List with a taxonomy field called "Categories"
                // Add List=GUID to the URL parameters of the custom aspx page used to view this list,
                // where GUID is the ID of the list.

                // Binds the TaxonomyFieldControl to the specified field
                myTaxonomyFieldControl.FieldName = "Categories";

                // A custom target template must be specified for the EmptyValueDescriptionForTargetTemplate property to have any effect
                TaxonomyField taxField = myTaxonomyFieldControl.Field as TaxonomyField;
                taxField.TargetTemplate = "_layouts/TestTaxonomyFieldControl.aspx";

                // Sets the default text to be rendered if the taxonomy field has an empty value and TargetTemplate is specified.
                // This property only takes effect if the ControlMode="display".
                myTaxonomyFieldControl.EmptyValueDescriptionForTargetTemplate = "No categories have been defined.";
            }
        }
    }
}

Cohérence de thread

Tous les membres statique (Partagé dans Visual Basic)s publics de ce type sont thread-safe. Cela n’est pas garanti pour les membres d’instance.

Voir aussi

Référence

TaxonomyFieldControl - Membres

Microsoft.SharePoint.Taxonomy - Espace de noms

TaxonomyWebTaggingControl