# TagTextBox

Namespace: **Wisej.Web**

Assembly: **Wisej.Framework** (4.0.0.0)

* [Control](/api/wisej.web/general/control.md)
  * [TextBoxBase](/api/wisej.web/editors/wisej.web.textboxbase.md)
    * [TagTextBox](/api/wisej.web/editors/tagtextbox.md)

Represents a data field that displays a list of selectable and removable tags. The control recognizes tags as the user types and adds in front of the editable field.

{% tabs %}
{% tab title="C#" %}

```csharp
public class TagTextBox : TextBoxBase
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class TagTextBox
    Inherits TextBoxBase
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](/files/hsR4ok3152WyAf8J2C1u) TagTextBox()

Initializes an instance of a [TagTextBox](/api/wisej.web/editors/tagtextbox.md) control.

## Properties

### ![](/files/hsR4ok3152WyAf8J2C1u) AllowDuplicateTags

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets whether duplicate tags are allowed.<mark style="color:blue;background-color:green;">Since 3.0.10</mark> (Default: `False`)

When a duplicate tag is rejected, the control fires the [TagRejected](#tagrejected) event.

### ![](/files/hsR4ok3152WyAf8J2C1u) Editable

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets whether the user can add tags by typing into the editable field. (Default: `True`)

### ![](/files/hsR4ok3152WyAf8J2C1u) KeepWatermark

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets whether the watermark should disappear when there is at least one tag. (Default: `False`)

### ![](/files/hsR4ok3152WyAf8J2C1u) MaxTagCount

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Returns or sets the maximum number of tags allowed in the control. When this limit is reached, the control will fire the [TagRejected](#tagrejected) event and will not add the tag. The default is 0 = unlimited. (Default: `0`)

### ![](/files/hsR4ok3152WyAf8J2C1u) MaxTagWidth

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Returns or sets the maximum width in pixels of the tag widgets displayed on the client. When the content exceeds this limit, it will show an ellipses. (Default: `100`)

### ![](/files/hsR4ok3152WyAf8J2C1u) MinFieldLength

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Returns or sets the minimum number of characters that should fit in the editable portion of the control before it wraps to a new line or displays the scroller for the tags portion. (Default: `10`)

### ![](/files/hsR4ok3152WyAf8J2C1u) SelectedText

[String](https://docs.microsoft.com/dotnet/api/system.string): Returns the text of the selected tag.

### ![](/files/hsR4ok3152WyAf8J2C1u) SelectionLength

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Returns the length of the selected tag.

### ![](/files/hsR4ok3152WyAf8J2C1u) SelectionStart

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Returns the position of the selected tag.

### ![](/files/hsR4ok3152WyAf8J2C1u) SeparatorChar

[Char](https://docs.microsoft.com/dotnet/api/system.char): Returns or sets the character used to separate the tags. (Default: `,`)

### ![](/files/hsR4ok3152WyAf8J2C1u) ShowToolTips

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets whether to show a tooltip with the full content of the tag text when the mouse hovers over the tag element. (Default: `False`)

### ![](/files/hsR4ok3152WyAf8J2C1u) TagCount

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Returns the number of tags in the control.

## Methods

### ![](/files/lzopMboA31bVq8UIcbT3) OnAutoSizeChanged(e)

| Parameter | Type                                                                | Description |
| --------- | ------------------------------------------------------------------- | ----------- |
| **e**     | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) |             |

### ![](/files/lzopMboA31bVq8UIcbT3) OnSeparatorCharChanged(e)

Fires the [SeparatorCharChanged](#separatorcharchanged) event.

| Parameter | Type                                                                | Description                                                                                         |
| --------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| **e**     | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | A [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnTagAdded(e)

Fires the [TagAdded](#tagadded) event.

| Parameter | Type                                                                                      | Description                                                                                                               |
| --------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| **e**     | [TagTextBoxEventArgs](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxeventargs.md) | A [TagTextBoxEventArgs](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxeventargs.md) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnTagClick(e)

Fires the [TagClick](#tagclick) event.

| Parameter | Type                                                                                              | Description                                                                                                                       |
| --------- | ------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| **e**     | [TagTextBoxMousEventArgs](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxmouseventargs.md) | A [TagTextBoxMousEventArgs](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxmouseventargs.md) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnTagDoubleClick(e)

Fires the [TagDoubleClick](#tagdoubleclick) event.

| Parameter | Type                                                                                              | Description                                                                                                                       |
| --------- | ------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| **e**     | [TagTextBoxMousEventArgs](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxmouseventargs.md) | A [TagTextBoxMousEventArgs](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxmouseventargs.md) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnTagRejected(e)

Fires the [TagRejected](#tagrejected) event.

| Parameter | Type                                                                                      | Description                                                                                                               |
| --------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| **e**     | [TagTextBoxEventArgs](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxeventargs.md) | A [TagTextBoxEventArgs](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxeventargs.md) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnTagRemoved(e)

Fires the [TagRemoved](#tagremoved) event.

| Parameter | Type                                                                                      | Description                                                                                                               |
| --------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| **e**     | [TagTextBoxEventArgs](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxeventargs.md) | A [TagTextBoxEventArgs](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxeventargs.md) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnTagRender(e)

Fires the [TagRender](#tagrender) event.

| Parameter | Type                                                                                                  | Description                                                                                                                           |
| --------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| **e**     | [TagTextBoxRenderEventArgs](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxrendereventargs.md) | A [TagTextBoxRenderEventArgs](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxrendereventargs.md) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnTagSelected(e)

Fires the [TagSelected](#tagselected) event.

| Parameter | Type                                                                                      | Description                                                                                                               |
| --------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| **e**     | [TagTextBoxEventArgs](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxeventargs.md) | A [TagTextBoxEventArgs](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxeventargs.md) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnWebEvent(e)

| Parameter | Type                                                        | Description |
| --------- | ----------------------------------------------------------- | ----------- |
| **e**     | [WisejEventArgs](/api/wisej.core/general/wisejeventargs.md) |             |

### ![](/files/lzopMboA31bVq8UIcbT3) OnWebRender(config)

| Parameter  | Type                                                          | Description |
| ---------- | ------------------------------------------------------------- | ----------- |
| **config** | [Object](https://docs.microsoft.com/dotnet/api/system.object) |             |

### ![](/files/hsR4ok3152WyAf8J2C1u) SelectTag(tag)

Selects the specified tag, if it exists. If the tag is selected successfully, it will fire the [TagSelected](#tagselected) event.

| Parameter | Type                                                          | Description                |
| --------- | ------------------------------------------------------------- | -------------------------- |
| **tag**   | [String](https://docs.microsoft.com/dotnet/api/system.string) | Text of the tag to select. |

## Events

### ![](/files/hsR4ok3152WyAf8J2C1u) SeparatorCharChanged

[EventHandler](https://docs.microsoft.com/dotnet/api/system.eventhandler) Fired when the value of [SeparatorChar](#separatorchar) changes.

### ![](/files/hsR4ok3152WyAf8J2C1u) TagAdded

[TagTextBoxEventHandler](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxeventhandler.md) Fired when the user adds new tag is added to the control.

### ![](/files/hsR4ok3152WyAf8J2C1u) TagClick

[TagTextBoxMousEventHandler](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxmouseventhandler.md) Fired when the user clicks (or taps) on a tag outside of the close icon.

### ![](/files/hsR4ok3152WyAf8J2C1u) TagDoubleClick

[TagTextBoxMousEventHandler](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxmouseventhandler.md) Fired when the user double clicks (or double taps) on a tag outside of the close icon.

### ![](/files/hsR4ok3152WyAf8J2C1u) TagRejected

[TagTextBoxEventHandler](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxeventhandler.md) Fired when the user tries to add a tag that already exists or the maximum number of allowed tags set in [MaxTagCount](#maxtagcount) is reached.

### ![](/files/hsR4ok3152WyAf8J2C1u) TagRemoved

[TagTextBoxEventHandler](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxeventhandler.md) Fired when the user removes a tag from the control.

### ![](/files/hsR4ok3152WyAf8J2C1u) TagRender

[TagTextBoxRenderEventHandler](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxrendereventhandler.md) Fired when the control needs to render the tags in the [Text](/api/wisej.web/editors/wisej.web.textboxbase.md#text) property.

Use this event to change the visual aspect of each tag on the client.

```csharp

private void tagTextBox1_TagRender(object sender, TagTextBoxRenderEventArgs e)
{
  switch (e.Text)
  {
    case "Arizona":
      e.BackColor = Color.Beige;
      break;

    case "Florida":
      e.BackColor = Color.LightGreen;
      break;

    case "Alaska":
      e.Html = "<b>" + e.Text + "</b>";
      break;

    case "California":
      e.Html = "<u>" + e.Text + "</u>";
      break;

    case "Georgia":
      e.Html = "<img src='Images/fullstar.png' style='display:inline-block;float:left;padding-right:5px' width='16'/>" + e.Text;
      break;
  }
}

```

### ![](/files/hsR4ok3152WyAf8J2C1u) TagSelected

[TagTextBoxEventHandler](/api/wisej.web/editors/tagtextbox/wisej.web.tagtextboxeventhandler.md) Fires when the user selects a tag.

## Implements

| Name                                                                              | Description                                                                                                                                                                                                                                     |
| --------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [IUserData](/api/wisej.web/interfaces/wisej.web.iuserdata.md)                     | Provides access to the `UserData` and `Tag` properties associated to the component implementing this interface.                                                                                                                                 |
| [IBindableComponent](/api/wisej.web/data-binding/wisej.web.ibindablecomponent.md) | Bindable components implement this interface.                                                                                                                                                                                                   |
| [IDropTarget](/api/wisej.web/interfaces/wisej.web.idroptarget.md)                 | Controls that support drag & drop operations implement this interface.                                                                                                                                                                          |
| [ILabel](/api/wisej.web/interfaces/wisej.web.ilabel.md)                           | Provides access to the [LabelWrapper](/api/wisej.web/editors/wisej.web.labelwrapper.md) associated with the controls that implement this interface.                                                                                             |
| [IReadOnly](/api/wisej.web/interfaces/wisej.web.ireadonly.md)                     | Provides access to the [ReadOnly](/api/wisej.web/interfaces/wisej.web.ireadonly.md#readonly) property for coontrols that support the read-only mode.                                                                                            |
| [IModified](/api/wisej.web/interfaces/wisej.web.imodified.md)                     | Provides access to the [Modified](/api/wisej.web/interfaces/wisej.web.imodified.md#modified) property and [ModifiedChanged](/api/wisej.web/interfaces/wisej.web.imodified.md#modifiedchanged) event for controls that implement this interface. |
| [IValidation](/api/wisej.web/interfaces/wisej.web.ivalidation.md)                 | Provides access to the validation events and properties property for controls that support validation.                                                                                                                                          |
| [IWisejComponent](/api/wisej.core/interfaces/wisej.core.iwisejcomponent.md)       | All wisej components implement this interface.                                                                                                                                                                                                  |
| [IWisejControl](/api/wisej.core/interfaces/wisej.core.iwisejcontrol.md)           | All wisej controls derived from the [Control](/api/wisej.web/general/control.md) class must implement this interface.                                                                                                                           |
| [IWisejSerializable](/api/wisej.core/interfaces/wisej.core.iwisejserializable.md) | Allows an object to serialize itself.                                                                                                                                                                                                           |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/api/wisej.web/editors/tagtextbox.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
