# TextBox

The [Wisej.Web.TextBox](https://docs.wisej.com/wisej-api/namespaces/wisej.web/textbox) control enables users to enter unformatted text.

The `TextBox` control accepts a single line of text. Enable the `Multiline` property to allow multiple lines of text input.

{% hint style="info" %}
For a full list of properties, methods and events see the [API documentation.](http://docs.wisej.com/api)
{% endhint %}

## Features

### Label

The `TextBox` control supports the inline [Label](/docs/controls/general/labels.md) property. This allows setting a label in relation to a `TextBox` control without creating an additional `Label` control.

![TextBox with label](/files/-MKGbH6-D_eAhwFSPlH_)

{% content-ref url="/pages/-MIuBO1zCPpT0Jut8LQd" %}
[Labels](/docs/controls/general/labels.md)
{% endcontent-ref %}

### Data Binding

Data binding supports formatting and value conversion through the default [data binding](/docs/controls/general/data-binding.md) infrastructure. The default data property is `Text`.

{% content-ref url="/pages/-MKGKoU8Qzujt6RqLS\_d" %}
[Data Binding](/docs/controls/general/data-binding.md)
{% endcontent-ref %}

### Spell Checking

Enable the browser's built-in spell checking by setting the `SpellCheck` property to `true`.

![TextBox with spell checking enabled](/files/-MKGdNv8FsentjrxMF_Q)

This functionality relies on the browser's language and spell checking support. Third-party spell checking is possible but outside Wisej.NET functionality.

### Tool Buttons

A key Wisej.NET feature available in most controls. The [Tools](/docs/controls/general/embedded-tools.md) property enables adding internal buttons aligned left or right, with user clicks handled through the `ToolClicked` event.

![TextBox with tool buttons](/files/-MKGegIf6_euDyyJGSRO)

{% content-ref url="/pages/-MFpKJgRghNfuMX-nf4u" %}
[Embedded Tools](/docs/controls/general/embedded-tools.md)
{% endcontent-ref %}

### Lazy Events

Some `TextBox` events fire only when a handler is attached. This prevents unnecessary browser requests unless explicitly subscribed.

The `KeyDown` event is a [Lazy Event](https://docs.wisej.com/docs/controls/general/lazy-events#lazy-events), preventing ajax requests for each character typed.

{% hint style="warning" %}
When extending a control class and overriding On\[EventName] for a lazy event without attaching a handler, the code won't execute unless a handler is attached.
{% endhint %}

{% content-ref url="/pages/-MKGGN1xam1geFM3sYEg" %}
[Events](/docs/controls/general/lazy-events.md)
{% endcontent-ref %}

### Watermark

All Wisej.NET editable controls include the `Watermark` property, displaying background text in empty fields.

Wisej.NET renders the watermark using the [placeholder](https://developer.mozilla.org/en-US/docs/Web/CSS/::placeholder) HTML attribute when supported, otherwise creating an overlaid label managed by the Wisej.NET JavaScript library.

![TextBox with watermark](/files/-MKGrmBE3Js_vpepyGAv)

### Password

Set the `PasswordChar` property to any character or the `InputType` to `Password` for a password input field. The `PasswordChar` value always converts to "\*" as browsers control password field display. This property exists for WinForms migration compatibility.

{% hint style="info" %}
For a password visibility toggle, add a tool icon and switch `InputType` between `Text` and `Password`.
{% endhint %}

### Character Casing

The `CharacterCasing` property forces text case transformation on both client and server. Wisej.NET performs the change while typing (client) and when setting the Text property (server).

## How To

### Enter tab or enter

By default, Tab moves focus to the next control and Enter does nothing. For tab characters and newlines, set `Multiline` to `true` and enable `AcceptsTab` or `AcceptsReturn`.

### Filter keyboard input

Limit accepted characters using either:

1. Set the `Filter` property to a [regular expression](https://regex101.com)
2. Handle the keydown [event on the client](https://docs.wisej.com/api/wisej.web/general/control#clientevents) with JavaScript

Server-side `KeyDown` handling cannot prevent character input as the browser processes it before server communication.

![Equivalent to setting Filter = "\[a-zA-Z\]"](/files/-MKGr86xdp-cj72hqp7O)

### Customize the appearance

Customize `TextBox` appearance through:

1. Properties (`BackColor`, `ForeColor`, `BorderStyle`, `Font`)
2. Custom [theme](https://docs.wisej.com/theme-builder/)
3. Theme mixin
4. Custom styles

For specialized UI like Material-3 animated underline on focus, use theme customization or custom styles.

![TextBox with custom border radius](/files/-MKGx1DQQy6LsGKGre_r)

The image shows a `TextBox` with "border-radius:20px" in `CssStyle`. For shared styles, use `CssClass` and add a StyleSheet file through Default.html or the [StyleSheet](/docs/controls/extenders/stylesheet.md) extender.

### Native Input Types

The `TextBox` supports various [\<input>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) types through the `InputType` property.

![Native input types in Chrome](/files/-MKGajh8TjptsEtR-rki)

{% hint style="info" %}
Native input styling is limited to browser-specific CSS properties outside the Wisej.NET theme system.
{% endhint %}

The `Text` property always returns a string representing the native input value. Special input types have specific behaviors:

**Radio**

Clicking toggles the `Checked` property and fires `CheckedChanged` (not `TextChanged`). Checked value is "on".

{% hint style="danger" %}
Browsers don't fire events for \<input type=radio>. Content localization depends on browser language.
{% endhint %}

**Checkbox**

Clicking toggles the `Checked` property and fires `CheckedChanged` (not `TextChanged`). Checked value is "on".

## Advanced

### AutoComplete

The `AutoCompleteList` property enables browser native autocomplete with a string array.

![TextBox with autocomplete list](/files/-MKGLopovrA93lAtokJ0)

Browser filters the `AutoCompleteList` as users type.

![TextBox showing filtered autocomplete options](/files/-MKGMWeCoXBWL_zLLaQb)

The `AutoComplete` property controls this feature. When enabled, browsers may build their own suggestions.

Common `AutoComplete` options include:

| Option          | Description                                                   |
| --------------- | ------------------------------------------------------------- |
| Email           | An email address                                              |
| Username        | A username or account name                                    |
| NewPassword     | A new password field for account creation or password changes |
| CurrentPassword | The user's current password                                   |
| OneTimeCode     | A one-time verification code                                  |

See [Mozilla Developer Site](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) for all options.

{% hint style="danger" %}
Browser implementation controls this functionality, including when to use previous values.
{% endhint %}

### Select content when focused

Wisej.NET selects all text when tabbing between fields. Clicking places the cursor at click location.

Enable `SelectOnEnter` for automatic text selection on any focus method.

### Native context menu

`EnableNativeContextMenu` (default: `true`) controls the browser's context menu on right-click. Disable to prevent the native menu.

{% hint style="info" %}
An assigned [ContextMenu](https://docs.wisej.com/api/wisej.web/menus/wisej.web.contextmenu) always overrides the native menu.
{% endhint %}

### JavaScript Widget

| Item                | Description                                                                                                         |
| ------------------- | ------------------------------------------------------------------------------------------------------------------- |
| Class name          | "wisej.web.TextBox" or "wisej.web.TextArea" when Multiline is true                                                  |
| Theme appearance    | "textbox", see [Themes](https://docs.wisej.com/theme-builder/theme-elements/elements)                               |
| Child components    | "textfield" is the inner \<input> widget. See [JavaScript](/docs/concepts/javascript-object-model.md)               |
| Toolcontainer state | "editor", see [Embedded Tools](/docs/controls/general/embedded-tools.md)                                            |
| Source code         | [https://github.com/iceteagroup/wisej-js](https://github.com/iceteagroup/wisej-js/blob/master/wisej.web.TextBox.js) |


---

# 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/docs/controls/editors/textbox.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.
