TaxonomyFieldControl TaxonomyFieldControl TaxonomyFieldControl Class

Definition

Provides the edit experience for a Microsoft.SharePoint.TaxonomyField object.

public ref class TaxonomyFieldControl sealed : Microsoft::SharePoint::WebControls::BaseFieldControl
public sealed class TaxonomyFieldControl : Microsoft.SharePoint.WebControls.BaseFieldControl
Public NotInheritable Class TaxonomyFieldControl
Inherits BaseFieldControl
Inheritance

Examples

<pre><code>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:
        // &lt;Taxonomy:TaxonomyFieldControl id="myTaxonomyFieldControl" ControlMode="display" runat="server" /&gt;
        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.";
            }
        }
    }
}

Remarks

The taxonomy field control contains a taxonomy Web tagging control. It is reponsiblefor initializing a new instance of the Web tagging control with all of the properties for the TaxonomyField object. It also initializes the taxonomy Web tagging control with its initial value, and then updates the TaxonomyField object with the selected value after edit.

Constructors

TaxonomyFieldControl() TaxonomyFieldControl() TaxonomyFieldControl()

Initializes a new instance of a TaxonomyFieldControl object.

Properties

AllowFirstFocus AllowFirstFocus AllowFirstFocus Inherited from BaseFieldControl
AlternateTemplate AlternateTemplate AlternateTemplate Inherited from TemplateBasedControl
AlternateTemplateName AlternateTemplateName AlternateTemplateName Inherited from TemplateBasedControl
CanCacheRenderedFieldValue CanCacheRenderedFieldValue CanCacheRenderedFieldValue Inherited from BaseFieldControl
ComponentRequiresPostback ComponentRequiresPostback ComponentRequiresPostback Inherited from BaseFieldControl
ControlMode ControlMode ControlMode Inherited from FormComponent
Controls Controls Controls Inherited from TemplateBasedControl
ControlTemplate ControlTemplate ControlTemplate Inherited from TemplateBasedControl
CssClass CssClass CssClass Inherited from BaseFieldControl
CustomAlternateTemplate CustomAlternateTemplate CustomAlternateTemplate Inherited from TemplateBasedControl
CustomTemplate CustomTemplate CustomTemplate Inherited from TemplateBasedControl
DefaultAlternateTemplateName DefaultAlternateTemplateName DefaultAlternateTemplateName Inherited from TemplateBasedControl
DefaultTemplateName DefaultTemplateName DefaultTemplateName Inherited from TemplateBasedControl
DisableInputFieldLabel DisableInputFieldLabel DisableInputFieldLabel Inherited from BaseFieldControl
DisplaySize DisplaySize DisplaySize Inherited from FieldMetadata
DisplayTemplate DisplayTemplate DisplayTemplate Inherited from BaseFieldControl
DisplayTemplateName DisplayTemplateName DisplayTemplateName Inherited from BaseFieldControl
EmptyValueDescriptionForTargetTemplate EmptyValueDescriptionForTargetTemplate EmptyValueDescriptionForTargetTemplate

Gets or sets the message that will be displayed in Display mode when the Taxonomy field has an empty value and the TargetTemplate is specified.

EnableInputFieldLabels EnableInputFieldLabels EnableInputFieldLabels Inherited from FormComponent
ErrorMessage ErrorMessage ErrorMessage Inherited from BaseFieldControl
Field Field Field Inherited from FieldMetadata
FieldName FieldName FieldName Inherited from FieldMetadata
Fields Fields Fields Inherited from FormComponent
HasPostBackEditData HasPostBackEditData HasPostBackEditData Inherited from BaseFieldControl
InDesign InDesign InDesign Inherited from SPControl
InputFieldLabel InputFieldLabel InputFieldLabel Inherited from BaseFieldControl
IsClientRenderedForm IsClientRenderedForm IsClientRenderedForm Inherited from FormComponent
IsEditMode IsEditMode IsEditMode Inherited from FormComponent
IsFieldValueCached IsFieldValueCached IsFieldValueCached Inherited from BaseFieldControl
IsInDesignTimeMode IsInDesignTimeMode IsInDesignTimeMode Inherited from BaseFieldControl
IsInInlineEditMode IsInInlineEditMode IsInInlineEditMode Inherited from BaseFieldControl
IsValid IsValid IsValid Inherited from BaseFieldControl
Item Item Item Inherited from FormComponent
ItemContext ItemContext ItemContext Inherited from FormComponent
ItemFieldValue ItemFieldValue ItemFieldValue Inherited from BaseFieldControl
ItemId ItemId ItemId Inherited from FormComponent
ItemIdAsString ItemIdAsString ItemIdAsString Inherited from FormComponent
List List List Inherited from FormComponent
ListFormWP ListFormWP ListFormWP Inherited from FormComponent
ListId ListId ListId Inherited from FormComponent
ListItem ListItem ListItem Inherited from FormComponent
ListItemFieldValue ListItemFieldValue ListItemFieldValue Inherited from BaseFieldControl
PageUri PageUri PageUri Inherited from SPControl
PreviousControlMode PreviousControlMode PreviousControlMode Inherited from BaseFieldControl
RecurrenceID RecurrenceID RecurrenceID Inherited from FormComponent
RedirectUrl RedirectUrl RedirectUrl Inherited from FormComponent
RegisterAs RegisterAs RegisterAs Inherited from SPControl
RenderContext RenderContext RenderContext Inherited from TemplateBasedControl
RibbonCommand RibbonCommand RibbonCommand Inherited from FormComponent
RibbonContextualGroupCommand RibbonContextualGroupCommand RibbonContextualGroupCommand Inherited from FormComponent
RibbonGroupCommand RibbonGroupCommand RibbonGroupCommand Inherited from FormComponent
RibbonTabCommand RibbonTabCommand RibbonTabCommand Inherited from FormComponent
TabIndex TabIndex TabIndex Inherited from BaseFieldControl
Template Template Template Inherited from TemplateBasedControl
TemplateContainer TemplateContainer TemplateContainer Inherited from TemplateBasedControl
TemplateName TemplateName TemplateName Inherited from TemplateBasedControl
TemplateOverride TemplateOverride TemplateOverride Inherited from TemplateBasedControl
Value Value Value

Gets or sets the value of the current TaxonomyFieldControl object.

Version Version Version Inherited from TemplateBasedControl
Visible Visible Visible Inherited from BaseFieldControl
Web Web Web Inherited from TemplateBasedControl

Methods

CreateChildControls() CreateChildControls() CreateChildControls() Inherited from BaseFieldControl
Focus() Focus() Focus() Inherited from BaseFieldControl
GetDesignTimeHtml() GetDesignTimeHtml() GetDesignTimeHtml() Inherited from SPControl
GetMultipleValueText(TaxonomyFieldValueCollection) GetMultipleValueText(TaxonomyFieldValueCollection) GetMultipleValueText(TaxonomyFieldValueCollection)

Converts a TaxonomyFieldValueCollection object into a string that can be used to apply to the Text property or to the Taxonomy TextField of a list item.

GetTaxonomyCollection(String) GetTaxonomyCollection(String) GetTaxonomyCollection(String)

Converts a string to a TaxonomyFieldValueCollection object,

GetTaxonomyValue(String) GetTaxonomyValue(String) GetTaxonomyValue(String)

Converts a string to a TaxonomyFieldValue object.

OnInit(EventArgs) OnInit(EventArgs) OnInit(EventArgs) Inherited from BaseFieldControl
OnLoad(EventArgs) OnLoad(EventArgs) OnLoad(EventArgs) Inherited from BaseFieldControl
OnPreRender(EventArgs) OnPreRender(EventArgs) OnPreRender(EventArgs) Inherited from BaseFieldControl
RegisterFieldControl() RegisterFieldControl() RegisterFieldControl() Inherited from BaseFieldControl
Render(HtmlTextWriter) Render(HtmlTextWriter) Render(HtmlTextWriter) Inherited from BaseFieldControl
RenderFieldForDisplay(HtmlTextWriter) RenderFieldForDisplay(HtmlTextWriter) RenderFieldForDisplay(HtmlTextWriter) Inherited from BaseFieldControl
RenderFieldForInput(HtmlTextWriter) RenderFieldForInput(HtmlTextWriter) RenderFieldForInput(HtmlTextWriter) Inherited from BaseFieldControl
RenderValidationMessage(HtmlTextWriter) RenderValidationMessage(HtmlTextWriter) RenderValidationMessage(HtmlTextWriter) Inherited from BaseFieldControl
UpdateFieldValueInItem() UpdateFieldValueInItem() UpdateFieldValueInItem()

Overrides the base field control implemenation of UpdateFieldValueInItem and ensures that the taxonoym field is updated along with its corresponding TextField.

Validate() Validate() Validate()

Overrides the BaseFieldControl.Validate method to ensure that all taxonomy data is valid.

Explicit Interface Implementations

IDesignerEventAccessor.OnDesignerLoad(EventArgs) IDesignerEventAccessor.OnDesignerLoad(EventArgs) IDesignerEventAccessor.OnDesignerLoad(EventArgs) Inherited from SPControl
IDesignerEventAccessor.OnDesignerPreRender(EventArgs) IDesignerEventAccessor.OnDesignerPreRender(EventArgs) IDesignerEventAccessor.OnDesignerPreRender(EventArgs) Inherited from SPControl

Fields

strShowSearchFormKey strShowSearchFormKey strShowSearchFormKey Inherited from SPControl

Applies to