TextBoxGroup

in namespace DotVVM.Framework.Controls.Bootstrap

Represents a group of Label and TextBox in the Form control.

Usage & Scenarios

Represents a group of Label and TextBox in the Form control.

Sample 1: Basic Text Box Group

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

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

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

<bs:TextBoxGroup LabelText="{value: LabelText}" Text="{value: ValueText}" />

<bs:TextBoxGroup LabelText="No value" />
using DotVVM.Framework.ViewModel;

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

Sample 2: Text Box Group - Enabled and Visible

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

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

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

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

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

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

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

Sample 3: Text Box Group - Format String

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

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

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

Sample 4: Text Box Group - Type and ValueType

The Type 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

The ValueType property is used for changing the type of value being formatted. Possible values are:

  • Text
  • DateTime
  • Number
<bs:TextBoxGroup LabelText="Password box" Text="password" Type="Password" />

<bs:TextBoxGroup LabelText="Numeric value" Text="0" ValueType="Number" />

Sample 5: Text Box Group - UpdateTextAfterKeydown and Changed

If you need property binded to Text property to update after every pressed key just set the UpdateTextAfterKeydown 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:TextBoxGroup LabelText="Update test" Text="{value: UpdateTestText}" UpdateTextAfterKeydown="true" />
<span>{{value: UpdateTestText}}</span>

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

namespace DotvvmWeb.Views.Docs.Controls.bootstrap.TextBoxGroup.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 ClientIDMode ClientIDMode Gets or sets the client ID generation algorithm.
attribute
inner element
static value
bindable
default
1
property icon DataContext Object Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value.
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 FormContent List<DotvvmControl> Gets or sets the content of the form group.
attribute
inner element
static value
bindable
default
null
property icon ID String Gets or sets the unique control ID.
attribute
inner element
static value
bindable
default
null
property icon InnerText String Gets or sets the inner text of the HTML element.
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 RenderContentContainers Boolean Gets or sets whether an additional container will be rendered around the content.
attribute
inner element
static value
bindable
default
True
property icon Text String Gets or sets the text in the TextBox.
attribute
inner element
static value
bindable
default
null
property icon Type TextBoxType Gets or sets the mode of the text field.
attribute
inner element
static value
bindable
default
0
property icon UpdateTextAfterKeydown 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 ValueType FormatValueType Gets or sets the type of value being formatted - Number or DateTime.
attribute
inner element
static value
bindable
default
0
property icon Visible Boolean Gets or sets whether the control is visible.
attribute
inner element
static value
bindable
default
True

Events

Name Type Description
event icon Changed Command Gets or sets the command that will be triggered when the control state is changed.

HTML produced by the control