TextBoxFormGroup

in namespace DotVVM.Framework.Controls.Bootstrap4

Renders a FormGroup control with a TextBox

Usage & Scenarios

Represents a TextBox in FormGroup.

Sample 1: Basic Text Box Form Group

The TextBoxFormGroup control has the LabelText property for the label and the Text property for text inside the text field.

Both these properties can also be bound to properties in viewmodel.

<bs:Form>
    <bs:TextBoxFormGroup LabelText="Static label" Text="Static value" />

    <bs:TextBoxFormGroup LabelText="{value: LabelText}" Text="{value: ValueText}" />
</bs:Form>
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.bootstrap4.TextBoxFormGroup.sample1
{
    public class ViewModel : DotvvmViewModelBase
    {
        public string LabelText { get; set; } = "Bound label";
        public string ValueText { get; set; } = "Bound value";
    }
}

Sample 2: Text Box Form Group - Enabled and Visible

The Enabled property is used to enable / disable the TextBoxFormGroup control.

It is also possible to show / hide the TextBoxFormGroup control with the Visible property.

<bs:Form>
    <bs:TextBoxFormGroup LabelText="Label" Text="Enabled textbox" Enabled="true" />

    <bs:TextBoxFormGroup LabelText="Label" Text="Disabled textbox" Enabled="false" />

    <bs:TextBoxFormGroup LabelText="Label" Text="Visible textbox" Visible="{value: TrueValue}" />

    <bs:TextBoxFormGroup LabelText="Label" Text="Invisible textbox" Visible="{value: FalseValue}" />
</bs:Form>
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.bootstrap4.TextBoxFormGroup.sample2
{
    public class ViewModel : DotvvmViewModelBase
    {
        public bool TrueValue { get; set; } = true;
        public bool FalseValue { get; set; } = false;
    }
}

Sample 3: Text Box Form Group - Format String

The content of TextBox can be formatted with the FormatString property if needed.

<bs:Form>
    <bs:TextBoxFormGroup LabelText="Formatting string" Text="{value: NumberValue}" FormatString="#0.00" />
</bs:Form>
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.bootstrap4.TextBoxFormGroup.sample3
{
    public class ViewModel : DotvvmViewModelBase
    {
        public double NumberValue { get; set; } = 123.456789;
    }
}

Sample 4: Text Box Form Group - Type

The TextBoxType property is used to change the mode of the text field. Possible values are:

  • Normal
  • Password
  • MultiLine
  • Telephone
  • Url
  • Email
  • Date
  • Time
  • Color
  • Search
  • Number
<bs:Form>
    <bs:TextBoxFormGroup LabelText="Password box" Text="password" TextBoxType="Password" />
</bs:Form>    

Sample 5: Text Box Form Group - UpdateTextOnInput and Changed

If you need property bound to Text property to update after every pressed key just set the UpdateTextOnInput property to true.

With the Changed property it is possible to bind to onchange event and perform specific actions when the value of text field changes.

<bs:Form>
    <bs:TextBoxFormGroup LabelText="Update test" Text="{value: UpdateTestText}" UpdateTextOnInput="true" />
    <span>{{value: UpdateTestText}}</span>

    <bs:TextBoxFormGroup LabelText="OnChanged test" Text="{value: ChangedTestText}" Changed="{command: Changed()}" />
    <span>{{value: ChangedValue}}</span>
</bs:Form>
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.bootstrap4.TextBoxFormGroup.sample5
{
    public class ViewModel : DotvvmViewModelBase
    {
        public string UpdateTestText { get; set; } = "Change this";
        public string ChangedValue { get; set; } = "Not changed";
        public string ChangedTestText { get; set; } = "text";

        public void Changed()
        {
            ChangedValue = "Changed to " + ChangedTestText;
        }
    }
}

Properties

Name Type Description Notes Default Value
property icon ContentTemplate List<DotvvmControl> Gets or sets the content of the form group.
attribute
inner element
static value
bindable
default
null
property icon ControlID String Gets or sets the ID of the main control inside the FormGroup to be associated with the label.
attribute
inner element
static value
bindable
default
null
property icon Enabled Boolean Gets or sets a value indicating whether the control is enabled and can be modified.
attribute
inner element
static value
bindable
default
True
property icon FormatString String Gets or sets a format of presentation of value to client.
attribute
inner element
static value
bindable
default
null
property icon LabelSize Int32? Gets or sets the size of size the label area for all screen sizes. This applies only to the Horizontal forms.
attribute
inner element
static value
bindable
default
null
property icon LabelSizeLG Int32? Gets or sets the size of the label area large screen. This applies only to the Horizontal forms.
attribute
inner element
static value
bindable
default
null
property icon LabelSizeMD Int32? Gets or sets the size of the label area for medium screen. This applies only to the Horizontal forms.
attribute
inner element
static value
bindable
default
null
property icon LabelSizeSM Int32? Gets or sets the size of the label area small screen. This applies only to the Horizontal forms.
attribute
inner element
static value
bindable
default
null
property icon LabelSizeXL Int32? Gets or sets the size of the label area for extra large screen. This applies only to the Horizontal forms.
attribute
inner element
static value
bindable
default
null
property icon LabelTemplate ITemplate Gets or sets the template of the label area. This property cannot be combined with the LabelText property.
attribute
inner element
static value
bindable
default
null
property icon LabelText String Gets or sets the label text. This property cannot be combined with the LabelTemplate property.
attribute
inner element
static value
bindable
default
null
property icon SelectAllOnFocus Boolean Gets or sets whether all text inside the TextBox becomes selected when the element gets focused.
attribute
inner element
static value
bindable
default
False
property icon Size Size Gets or sets the size of controls in the form group.
attribute
inner element
static value
bindable
default
Default
property icon Text Object Gets or sets the text in the TextBox.
attribute
inner element
static value
bindable
default
property icon TextBoxType TextBoxType Gets or sets the mode of the text field.
attribute
inner element
static value
bindable
default
Normal
property icon Type FormGroupType Gets or sets the type of the form.
attribute
inner element
static value
bindable
default
Default
property icon UpdateTextOnInput Boolean Gets or sets whether the viewmodel property will be updated after the key is pressed. By default, the viewmodel is updated after the control loses its focus.
attribute
inner element
static value
bindable
default
False
property icon UsedControlIDList HashSet<String>
attribute
inner element
static value
bindable
default
null

Events

Name Type Description
event icon Changed Command Gets or sets the command that will be triggered when the onchange event is fired.

HTML produced by the control