Compartir a través de


Clase TaxonomyFieldControl

Ofrece la experiencia de edición de un objeto TaxonomyField .

Jerarquía de la herencia

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

Espacio de nombres:  Microsoft.SharePoint.Taxonomy
Ensamblado:  Microsoft.SharePoint.Taxonomy (en Microsoft.SharePoint.Taxonomy.dll)

Sintaxis

'Declaración
<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
'Uso
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

Comentarios

El control de campo de taxonomía contiene una taxonomía control etiquetado de Web. Es inicializar una nueva instancia del etiquetado de control con todas las propiedades para el objeto TaxonomyField Web de reponsiblefor. También inicializa la taxonomía control etiquetado de Web con su valor inicial y, a continuación, actualiza el objeto TaxonomyField con el valor seleccionado después de la edición.

Ejemplos

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.";
            }
        }
    }
}

Seguridad para subprocesos

Los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para subprocesos. No se garantiza que los miembros de instancias sean seguros para los subprocesos.

Vea también

Referencia

Miembros TaxonomyFieldControl

Espacio de nombres Microsoft.SharePoint.Taxonomy

TaxonomyWebTaggingControl