TaxonomyWebTaggingControl TaxonomyWebTaggingControl TaxonomyWebTaggingControl Class

Definition

Represents a generic Web control for picking managed metadata terms.

public ref class TaxonomyWebTaggingControl sealed : System::Web::UI::WebControls::WebControl
public sealed class TaxonomyWebTaggingControl : System.Web.UI.WebControls.WebControl
Public NotInheritable Class TaxonomyWebTaggingControl
Inherits WebControl
Inheritance
TaxonomyWebTaggingControlTaxonomyWebTaggingControlTaxonomyWebTaggingControl

Examples

<pre><code>using System;

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

namespace Microsoft.SDK.SharePointServer.Samples { public class TestTaxonomyWebTaggingControl : System.Web.UI.Page { // In order to place the TaxonomyWebTaggingControl on an aspx page use the following declaration: // &lt;Taxonomy:TaxonomyWebTaggingControl id="myTaxonomyControl" runat="server" /&gt; protected TaxonomyWebTaggingControl myTaxonomyControl;

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        if (IsPostBack)
        {
            // since this is a PostBack we want to validate
            string errorMessage = string.Empty;
            if (myTaxonomyControl.Validate(out errorMessage))
            {
                string value = myTaxonomyControl.Text;
                // now do what you want with the value returned from the control.
            }
            else
            {
                // The data was not valid so you need to inform the user
                throw new Exception("The data entered was not valid");
            }
        }
        else
        {
            TaxonomySession taxonomySession = new TaxonomySession(SPContext.Current.Site);

            // This code assumes you have a term store and term set set up already (we are just taking the first one
            myTaxonomyControl.SSPList = taxonomySession.TermStores[0].Id.ToString();
            myTaxonomyControl.TermSetList = taxonomySession.TermStores[0].Groups[0].TermSets[0].Id.ToString();
            myTaxonomyControl.GroupId = taxonomySession.TermStores[0].Groups[0].Id;
            // This controls whether you can add new terms to the term set
            myTaxonomyControl.AllowFillIn = false;
            // This controls whether we use an anchor term or not (by setting it to Empty we are explicitly choosing
            // not to)
            myTaxonomyControl.AnchorId = Guid.Empty;
            // Since we are bound to a specific term set and not spanning term sets the following property really does nothing
            myTaxonomyControl.ExcludeKeyword = false;
            // This controls whether unresolved terms will just be added to the termset or not
            myTaxonomyControl.IsAddTerms = false;
            // This setting allows you to browse the term set
            myTaxonomyControl.IsDisplayPickerButton = true;
            // This setting enables/disables validation highlighting
            myTaxonomyControl.IsIgnoreFormatting = false;
            myTaxonomyControl.IsIncludeDeprecated = false;
            myTaxonomyControl.IsIncludeUnavailable = false;
            // This setting modifies what is stored/returned from the control, if you want the GUIDS of parent terms
            // then set this to true
            myTaxonomyControl.IsIncludePathData = false;
            // This setting will include term set name resolution as well if set
            myTaxonomyControl.IsIncludeTermSetName = false;
            // This allows or disallows multiple values to be selected
            myTaxonomyControl.IsMulti = false;
            // We are searching on a specific termset so set these to false
            myTaxonomyControl.IsSpanTermSets = false;
            myTaxonomyControl.IsSpanTermStores = false;
            myTaxonomyControl.IsUseCommaAsDelimiter = false;
            // This is the LCID of the language to resolve terms against
            myTaxonomyControl.Language = taxonomySession.TermStores[0].DefaultLanguage;

            // This has a default value, however, if you want to customize what web service it uses you can
            // change the URL.
            myTaxonomyControl.WebServiceUrl = new Uri(SPContext.Current.Web.Url + "/_vti_bin/TaxonomyInternalService.json");

            myTaxonomyControl.SetCannotBeBlankErrorMessage("This control should not be blank");

            // If you want to modify the width/height of the control you will need to use the WidthCss/HeightCss 
            // properties and set them to a css class that defines the width/height properties.  The code would
            // be:
            // myTaxonomyControl.WidthCss = "my-css-class";
            // myTaxonomyControl.HeightCss = "my-css-class";
        }

    }
}

}

Remarks

A TaxonomyWebTaggingControl object is a Web control that can be added to a page so that a user can pick one or more taxonomy Term object from a specific TermSet object or from an entire TermStore object.

This control ensures that all terms are valid, and if they are not, it requires validation from the user when it finds an invalid term. If the TermStore or TermSet connection cannot be established, the TaxonomyWebTaggingControl will be disabled.

Constructors

TaxonomyWebTaggingControl() TaxonomyWebTaggingControl() TaxonomyWebTaggingControl()

Initializes a new instance of a TaxonomyWebTaggingControl object.

Properties

AllowFillIn AllowFillIn AllowFillIn

Gets or sets whether this control will give the option of adding new Term objects if the Microsoft.SharePoint.Taxonomy.TermSet.Open property is set.

AnchorId AnchorId AnchorId

Get or set the ID of the Microsoft.SharePoint.Taxonomy whose children will be used to validate against.

ContainerId ContainerId ContainerId

Returns the client ID of the top level DOM element for the TaxonomyWebTaggingControl object.

Disabled Disabled Disabled

This member has been deprecated and is not recommended for use in your code.

ExcludeKeyword ExcludeKeyword ExcludeKeyword

Gets and sets whether this control will resolve against keyword Term object or not.

FieldId FieldId FieldId

This member has been deprecated and is not recommended for use in your code.

FieldName FieldName FieldName

Gets and sets the value that will be shown in the ToolTip on the client.

GroupId GroupId GroupId

Gets and sets the IDs of the Group object that this control will validate against

HeightCss HeightCss HeightCss

Gets and sets a CSS class that will be applied to the control which should specify the heightCSS property value that will be applied to the control.

IsAddTerms IsAddTerms IsAddTerms

Gets and sets whether this control will try to add unresolved Term objects to the Microsoft.SharePont.Taxonomy.TermSet object.

IsDisplayPickerButton IsDisplayPickerButton IsDisplayPickerButton

Gets or sets whether this control will allow browsing with the picker.

IsIgnoreFormatting IsIgnoreFormatting IsIgnoreFormatting

Gets or sets whether this control will format valid and invalid Term objects or leave them as plain text.

IsIncludeDeprecated IsIncludeDeprecated IsIncludeDeprecated

Gets or sets whether this control will resolve against deprecated Term objects.

IsIncludePathData IsIncludePathData IsIncludePathData

Gets or sets whether this control will include the full GUID path for all Term objects.

IsIncludeTermSetName IsIncludeTermSetName IsIncludeTermSetName

Gets and sets whether this control will resolve against the names of TermSet object names.

IsIncludeUnavailable IsIncludeUnavailable IsIncludeUnavailable

Gets or sets whether this control will resolve against unavailable Term objects.

IsMulti IsMulti IsMulti

Gets or sets whether this control accepts multiple Term objects.

IsSpanTermSets IsSpanTermSets IsSpanTermSets

Gets and sets whether this control will resolve against all TermSet objects or only the TermSet objects provided.

IsSpanTermStores IsSpanTermStores IsSpanTermStores

Gets or sets whether this control will resolve against all TermStore objects or only the TermStore objects provided.

IsUIRightToLeft IsUIRightToLeft IsUIRightToLeft

This member has been deprecated and is not recommended for use in your code.

IsUseCommaAsDelimiter IsUseCommaAsDelimiter IsUseCommaAsDelimiter

Gets or sets whether this control will use a comma in addition to a semi-colon as a delimiter.

Language Language Language

Gets or sets the LCID representing the language this control will validate against.

SspId SspId SspId

Gets the IDs of the TermStore objects that this control will validate against.

SSPList SSPList SSPList

Gets and sets the IDs of the T:Microsoft.SharePoint.Taxonomy.TermStore objects that this control will validate against.

TermSetId TermSetId TermSetId

Gets the IDs of the TermSet object that this control will validate against.

TermSetList TermSetList TermSetList

Gets or sets the IDs of the TermSet object that this control will validate against

Text Text Text

Gets input from and sets output to the TaxonomyWebTaggingControl object.

WebServiceUrl WebServiceUrl WebServiceUrl

Gets and sets the URL of the TaxonomyInternalService that will be used to resolve against.

WidthCss WidthCss WidthCss

Gets or sets a CSS class that will be applied to the control that should specify a width CSS class.

Methods

GetValidatedTerms() GetValidatedTerms() GetValidatedTerms()

Gets the list of valid terms corresponding to the value of the Text property.

SetCannotBeBlankErrorMessage(String) SetCannotBeBlankErrorMessage(String) SetCannotBeBlankErrorMessage(String)

Sets a message to be shown if the field is empty.

SetValidatedTerms(List<Term>, String) SetValidatedTerms(List<Term>, String) SetValidatedTerms(List<Term>, String)

Sets the value of the Text property to correspond to the terms list, and triggers server-side validation of the new value.

Validate(String) Validate(String) Validate(String)

Checks whether the data in the current TaxonomyWebTaggingControl object is valid and tries to validate it if has not yet been validated.

Applies to