TextBoxExtensions
Wisej.Web.Markup.TextBoxExtensions
Namespace: Wisej.Web.Markup
Assembly: Wisej.Framework (4.0.0.0)
Adds fluent markup extension methods to the TextBox class.
public class TextBoxExtensions
Methods
AcceptsReturn<TTextBox>(textBox, value)

Sets whether the specified TextBox control accepts the Return key.
Returns: TTextBox. The modified text box with the updated AcceptsReturn property.
This method allows you to configure the text box to accept or ignore the Return key.
myTextBox.AcceptsReturn(true);
AcceptsTab<TTextBox>(textBox, acceptTab)

Sets whether the specified TextBoxBase control accepts the Tab key.
Returns: TTextBox. The modified text box with the updated AcceptsTab property.
AllowDuplicateTags<TTextBox>(tagTextBox, value)

Sets whether duplicate tags are allowed in the specified TagTextBox.
Returns: TTextBox. The modified tag text box with the updated AllowDuplicateTags property.
This method allows you to specify whether the text box can accept duplicate tag entries.
myTagTextBox.AllowDuplicateTags(false);
AutoComplete<TTextBox>(textBox, autoComplete)

Sets the auto-complete behavior for the specified TextBoxBase.
Returns: TTextBox. The modified text box with the updated auto-complete behavior.
AutoCompleteList<TTextBox>(textBox, list)

Sets the list of auto-complete options for the specified TextBoxBase.
Returns: TTextBox. The modified text box with the updated auto-complete list.
BorderStyle<TTextBox>(textBox, borderStyle)

Sets the border style of the specified TextBoxBase.
Returns: TTextBox. The modified text box with the updated border style.
CharacterCasing<TTextBox>(textBox, characterCasing)

Sets the character casing for the specified TextBox.
Returns: TTextBox. The modified text box with the updated character casing.
This method allows you to control the character casing for the text entered into the text box.
myTextBox.CharacterCasing(CharacterCasing.Upper);
Checked<TTextBox>(textBox, value)

Sets the checked state of the specified TextBox.
Returns: TTextBox. The modified text box with the updated checked state.
This method allows you to set the checked state for a text box control that supports a checked property.
myTextBox.Checked(true);
Culture<TTextBox>(typedTextBox, cultureInfo)

Sets the culture information to use for displaying and interpreting the value in the specified TypedTextBox.
Returns: TTextBox. The modified typed text box with the updated culture information.
This method allows you to set the culture information, which can affect how numbers, dates, and other data types are displayed or parsed in the typed text box.
myTypedTextBox.Culture(new CultureInfo("en-US"));
CustomFormat<TTextBox>(typedTextBox, customFormat)

Sets a custom format string for the specified TypedTextBox.
Returns: TTextBox. The modified typed text box with the updated custom format.
This method allows you to define a custom format string for displaying the value within the typed text box.
myTypedTextBox.CustomFormat("C2");
Filter<TTextBox>(textBox, filter)

Sets a filter string for the specified TextBox.
Returns: TTextBox. The modified text box with the applied filter string.
This extension method allows you to apply a filter to the text box content, possibly for validation or searching purposes.
myTextBox.Filter("^[a-zA-Z]+$");
InputType<TTextBox>(textBox, value)

Sets the input type for the specified TextBox.
Returns: TTextBox. The TextBox instance with the updated input type.
This method allows you to specify the input type for a TextBox control, which can be useful for customizing the behavior of the text input.
TextBox myTextBox = new TextBox();
myTextBox.InputType(InputType.Email);
Invalid<TTextBox>(textBox, invalid)

Sets the invalid status of the specified TextBoxBase.
Returns: TTextBox. The modified text box with the updated invalid status.
InvalidMessage<TTextBox>(textBox, message)

Sets the invalid message for the specified TextBoxBase.
Returns: TTextBox. The modified text box with the updated invalid message.
KeepFormatOnEnter<TTextBox>(typedTextBox, value)

Sets whether the format of the specified TypedTextBox should be retained when the text box is entered.
Returns: TTextBox. The modified typed text box with the updated KeepFormatOnEnter property.
This method allows you to specify whether the formatting of the value should be retained when the text box is entered.
myTypedTextBox.KeepFormatOnEnter(true);
KeepWatermark<TTextBox>(tagTextBox, value)

Sets whether the watermark text should remain visible when the specified TagTextBox loses focus.
value
A boolean value indicating whether the watermark should remain visible when the text box loses focus.
Returns: TTextBox. The modified tag text box with the updated KeepWatermark property.
This method allows you to specify whether the watermark text should persist when the text box loses focus.
myTagTextBox.KeepWatermark(false);
Lines<TTextBox>(textBox, lines)

Sets the lines of text in the specified TextBoxBase.
Returns: TTextBox. The modified text box with the updated lines of text.
Max<TInputType>(inputType, value)

Sets the maximum value for the input element.
Returns: TInputType. The modified input element with the specified maximum value.
MaxLength<TTextBox>(textBox, length)

Sets the maximum number of characters that can be entered into the specified TextBoxBase.
Returns: TTextBox. The modified text box with the updated maximum length.
MaxTagCount<TTextBox>(tagTextBox, count)

Sets the maximum number of tags that can be added to the specified TagTextBox.
Returns: TTextBox. The modified tag text box with the updated maximum tag count.
This method allows you to specify the maximum number of tags that can be added to the tag text box. If more tags are added than the specified count, they may be ignored or removed.
myTagTextBox.MaxTagCount(5);
MaxTagWidth<TTextBox>(tagTextBox, width)

Sets the maximum width for each tag in the specified TagTextBox.
Returns: TTextBox. The modified tag text box with the updated maximum tag width.
This method allows you to limit the width of each tag within the tag text box. Tags exceeding the specified width may be truncated or otherwise adjusted.
myTagTextBox.MaxTagWidth(100);
Min<TInputType>(inputType, value)

Sets the minimum value for the input element.
Returns: TInputType. The modified input element with the specified minimum value.
Mode<TInputType>(inputType, value)

Sets the mode of the input element.
Returns: TInputType. The modified input element with the specified mode.
Multiline<TTextBox>(textBox, multiLine)

Sets the Multiline property for the specified TextBox, enabling or disabling multiline text input.
Returns: TTextBox. The text box with the updated Multiline property.
This method allows you to specify whether the text box can accept multiple lines of text.
myTextBox.Multiline(true);
OnAcceptsTabChanged<TTextBox>(textBox, action)

Adds an event handler for the AcceptsTabChanged event of the specified TextBoxBase.
Returns: TTextBox. The text box with the attached event handler.
This extension method allows you to easily attach an action to execute when the AcceptsTab property of the text box changes.
myTextBox.OnAcceptsTabChanged(tb =>
{
AlertBox.Show("AcceptsTab property changed!");
});
OnCheckedChanged<TTextBox>(textBox, action)

Sets a checked state change event handler for the specified TextBoxBase.
Returns: TTextBox. The modified text box with the attached CheckedChanged event handler.
This method allows you to add an event handler for the CheckedChanged event, which occurs when the checked state changes.
myTextBox.OnCheckedChanged(tb =>
{
AlertBox.Show("Checked state changed!");
});
OnCultureChanged<TTextBox>(typedTextBox, action)

Attaches an event handler for the CultureChanged event of the specified TypedTextBox.
Returns: TTextBox. The modified typed text box with the attached CultureChanged event handler.
This method allows you to execute a custom action whenever the Culture property of the typed text box changes.
myTypedTextBox.OnCultureChanged(tb =>
{
AlertBox.Show("Culture changed!");
});
OnCustomFormatChanged<TTextBox>(typedTextBox, action)

Attaches an event handler for the CustomFormatChanged event of the specified TypedTextBox.
Returns: TTextBox. The modified typed text box with the attached CustomFormatChanged event handler.
This method allows you to execute a custom action whenever the CustomFormat property of the typed text box changes.
myTypedTextBox.OnCustomFormatChanged(tb =>
{
AlertBox.Show("Custom format changed!");
});
OnFormat<TTextBox>(typedTextBox, action)

Attaches an event handler for the Format event of the specified TypedTextBox.
action
An action to execute during the Format event, with the text box and event arguments as parameters.
Returns: TTextBox. The modified typed text box with the attached Format event handler.
This method allows you to define custom formatting logic by executing a specified action during the Format event.
myTypedTextBox.OnFormat((tb, args) =>
{
// Custom formatting logic
});
OnMultilineChanged<TTextBox>(textBox, action)

Adds an event handler for the MultilineChanged event of the specified TextBoxBase.
Returns: TTextBox. The text box with the attached event handler.
This extension method allows you to easily attach an action to execute when the Multiline property of the text box changes.
myTextBox.OnMultilineChanged(tb =>
{
AlertBox.Show("Multiline property changed!");
});
OnParse<TTextBox>(typedTextBox, action)

Attaches an event handler for the Parse event of the specified TypedTextBox.
action
An action to execute during the Parse event, with the text box and event arguments as parameters.
Returns: TTextBox. The modified typed text box with the attached Parse event handler.
This method allows you to define custom parsing logic by executing a specified action during the Parse event.
myTypedTextBox.OnParse((tb, args) =>
{
// Custom parsing logic
});
OnSeperatorCharChanged<TTextBox>(tagTextBox, action)

Attaches an event handler for the SeparatorCharChanged event of the specified TagTextBox.
Returns: TTextBox. The modified tag text box with the attached SeparatorCharChanged event handler.
This method allows you to add custom behavior when the SeparatorChar property of the tag text box changes.
myTagTextBox.OnSeperatorCharChanged(tb =>
{
AlertBox.Show("Separator character changed!");
});
OnTagAdded<TTextBox>(tagTextBox, action)

Attaches an event handler for the TagAdded event of the specified TagTextBox.
Returns: TTextBox. The modified tag text box with the attached TagAdded event handler.
This method allows you to execute a custom action when a new tag is added to the tag text box.
myTagTextBox.OnTagAdded((tb, args) =>
{
AlertBox.Show("Tag added: " + args.Tag);
});
OnTagClick<TTextBox>(tagTextBox, action)

Attaches an event handler for the TagClick event of the specified TagTextBox.
Returns: TTextBox. The modified tag text box with the attached TagClick event handler.
This method allows you to add an event handler for the TagClick event, executing a custom action when a tag is clicked.
myTagTextBox.OnTagClick((tb, args) =>
{
AlertBox.Show("Tag clicked: " + args.Tag);
});
OnTagDoubleClick<TTextBox>(tagTextBox, action)

Attaches an event handler for the TagDoubleClick event of the specified TagTextBox.
Returns: TTextBox. The modified tag text box with the attached TagDoubleClick event handler.
This method allows you to add an event handler for the TagDoubleClick event, allowing you to define custom behavior when a tag is double-clicked.
myTagTextBox.OnTagDoubleClick((tb, args) =>
{
AlertBox.Show("Tag double-clicked: " + args.Tag);
});
OnTagRejected<TTextBox>(tagTextBox, action)

Attaches an event handler for the TagRejected event of the specified TagTextBox.
Returns: TTextBox. The modified tag text box with the attached TagRejected event handler.
This method allows you to add an event handler for the TagRejected event, which occurs when a tag is not accepted for some reason.
myTagTextBox.OnTagRejected((tb, args) =>
{
AlertBox.Show("Tag rejected: " + args.Tag);
});
OnTagRemoved<TTextBox>(tagTextBox, action)

Adds an event handler for the TagRemoved event of the specified TagTextBox.
Returns: TTextBox. The modified tag text box with the attached TagRemoved event handler.
This extension method allows you to provide an action that will be executed when a tag is removed from the tag text box.
myTagTextBox.OnTagRemoved((tb, args) =>
{
AlertBox.Show("Tag removed: " + args.Tag);
});
OnTagRender<TTextBox>(tagTextBox, action)

Attaches an event handler for the TagRender event of the specified TagTextBox.
Returns: TTextBox. The modified tag text box with the attached TagRender event handler.
This method allows you to define a custom action for rendering tags within the tag text box.
myTagTextBox.OnTagRender((tb, args) =>
{
// Custom rendering logic
});
OnTagSelected<TTextBox>(tagTextBox, action)

Attaches an event handler for the TagSelected event of the specified TagTextBox.
Returns: TTextBox. The modified tag text box with the attached TagSelected event handler.
This method allows you to execute a custom action when a tag is selected within the tag text box.
myTagTextBox.OnTagSelected((tb, args) =>
{
AlertBox.Show("Tag selected: " + args.Tag);
});
OnTextAlignChanged<TTextBox>(textBox, action)

Attaches an event handler to the TextAlignChanged event of the specified TextBoxBase.
Returns: TTextBox. The modified text box with the attached TextAlignChanged event handler.
This method is used to add an event handler for the TextAlignChanged event, which occurs when the alignment of the text changes.
myTextBox.OnTextAlignChanged(tb =>
{
AlertBox.Show("Text alignment changed!");
});
OnToolClick<TTextBox>(textBox, action)

Attaches an event handler to the ToolClick event of the specified TextBoxBase.
Returns: TTextBox. The modified text box with the attached ToolClick event handler.
This method is used to add an event handler for the ToolClick event, which occurs when a tool button is clicked.
myTextBox.OnToolClick((tb, tool) =>
{
AlertBox.Show($"Tool clicked: {tool.ToolName}");
});
OnValueChanged<TTextBox>(typedTextBox, action)

Attaches an event handler for the ValueChanged event of the specified TypedTextBox.
Returns: TTextBox. The modified typed text box with the attached ValueChanged event handler.
This method allows you to execute a custom action whenever the Value property of the typed text box changes.
myTypedTextBox.OnValueChanged(tb =>
{
AlertBox.Show("Value changed!");
});
OnValueTypeChanged<TTextBox>(typedTextBox, action)

Attaches an event handler for the ValueTypeChanged event of the specified TypedTextBox.
Returns: TTextBox. The modified typed text box with the attached ValueTypeChanged event handler.
This method enables the execution of a custom action whenever the ValueType property of the typed text box changes.
myTypedTextBox.OnValueTypeChanged(tb =>
{
AlertBox.Show("Value type changed!");
});
PasswordChar<TTextBox>(textBox, passwordChar)

Sets the password character for the specified TextBox.
Returns: TTextBox. The modified text box with the updated password character.
This method allows you to specify a character to display in place of the actual characters typed for password input.
myTextBox.PasswordChar('*');
ScrollBars<TTextBox>(textBox, scrollBars)

Sets the scroll bars for the specified TextBox.
Returns: TTextBox. The modified text box with the updated scroll bars.
This method allows you to configure the scroll bars for the text box.
myTextBox.ScrollBars(ScrollBars.Both);
Selectable<TTextBox>(textBox, selectable)

Sets the selectable status of the specified TextBoxBase.
Returns: TTextBox. The modified text box with the updated selectable status.
SelectedText<TTextBox>(textBox, text)

Sets the selected text in the specified TextBoxBase.
Returns: TTextBox. The modified text box with the updated selected text.
SelectionLength<TTextBox>(textBox, length)

Sets the length of the selected text in the specified TextBoxBase.
Returns: TTextBox. The modified text box with the updated selection length.
SelectionStart<TTextBox>(textBox, index)

Sets the starting position of the text selection in the specified TextBoxBase.
Returns: TTextBox. The modified text box with the updated selection start.
SelectOnEnter<TTextBox>(textBox, selectOnEnter)

Sets whether the entire text is selected when the specified TextBoxBase is entered.
Returns: TTextBox. The modified text box with the updated SelectOnEnter property.
SeparatorChar<TTextBox>(tagTextBox, separator)

Sets the character used to separate tags in the specified TagTextBox.
Returns: TTextBox. The modified tag text box with the updated separator character.
This method allows you to customize the character that separates tags within the text box.
myTagTextBox.SeparatorChar(',');
ShowToolTips<TTextBox>(tagTextBox, value)

Sets whether tooltips are shown for tags in the specified TagTextBox.
Returns: TTextBox. The modified tag text box with the updated tooltip visibility setting.
This extension method allows you to enable or disable the display of tooltips for tags within the text box. Tooltips can provide additional information about each tag.
myTagTextBox.ShowToolTips(true);
SpellCheck<TTextBox>(textBox, value)

Enables or disables spell checking for the specified TextBox.
Returns: TTextBox. The TextBox instance with the updated spell check setting.
This method allows you to enable or disable spell checking for a TextBox control, which can be useful for providing feedback on text input.
TextBox myTextBox = new TextBox();
myTextBox.SpellCheck(true);
Step<TInputType>(inputType, value)

Sets the step value for the input element.
value
The step value as a nullable double. If null, the step attribute will be removed.
Returns: TInputType. The modified input element with the specified step value.
TextAlign<TTextBox>(textBox, textAlign)

Sets the horizontal text alignment for the specified TextBox.
Returns: TTextBox. The modified text box with the updated text alignment.
This method allows you to set the horizontal alignment of text within the text box.
myTextBox.TextAlign(HorizontalAlignment.Center);
Tools<TTextBox>(textBox, toolBarButtons)

Adds a collection of tool bar buttons to the specified TextBoxBase.
Returns: TTextBox. The modified text box with the added tool bar buttons.
Type<TInputType>(inputType, value)

Sets the type of the input element.
Returns: TInputType. The modified input element with the specified type.
Value<TTextBox>(typedTextBox, value)

Sets the value of the specified TypedTextBox.
Returns: TTextBox. The modified typed text box with the updated value.
This method allows you to set a value into the typed text box, which will be converted to a string representation according to the text box's ValueType and Culture settings.
myTypedTextBox.Value(123.45);
Watermark<TTextBox>(textBox, watermark)

Sets the watermark text for the specified TextBoxBase.
Returns: TTextBox. The modified text box with the updated watermark text.
WordWrap<TTextBox>(textBox, wrap)

Sets the word wrap status of the specified TextBoxBase.
Returns: TTextBox. The modified text box with the updated word wrap status.
Last updated
Was this helpful?