ToggleButton
in namespace DotVVM.BusinessPack.Controls
Usage & Scenarios
Renders the HTML button that can switch states like the CheckBox
Sample 1: Basic Usage
The ToggleButton control has the Checked
property of boolean which indicates whether the control is checked or not.
You can use the Text
property to specify the button text. Or you can put contents inside the bp:ToggleButton
element.
<bp:ToggleButton Text="Toggle button" Checked="{value: Checked}"/>
using System;
using DotVVM.Framework.ViewModel;
namespace DotvvmWeb.Views.Docs.Controls.businesspack.ToggleButton.sample1
{
public class ViewModel : DotvvmViewModelBase
{
public bool Checked { get; set; }
}
}
Sample 1: Basic Usage
You can set which command will be triggered when the button is clicked with click
property.
<bp:ToggleButton Checked="{value: Checked}"
Click="{command: ClickCount = ClickCount + 1}">
<span>Toggle button</span>
</bp:ToggleButton>
<p>Click counter: {{value: ClickCount}}</p>
using System;
using DotVVM.Framework.ViewModel;
namespace DotvvmWeb.Views.Docs.Controls.businesspack.ToggleButton.sample2
{
public class ViewModel : DotvvmViewModelBase
{
public bool Checked { get; set; }
public int ClickCount { get; set; }
}
}
Properties
Name | Type | Description | Notes | Default Value | |
---|---|---|---|---|---|
Attributes | Dictionary<String,Object> |
attribute
static value
|
null | ||
Checked | Boolean |
attribute
bindable
|
False | ||
ClientIDMode | ClientIDMode | Gets or sets the client ID generation algorithm. |
attribute
static value
|
Static | |
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
static value
bindable
|
null | |
Enabled | Boolean |
attribute
static value
bindable
|
False | ||
ID | String | Gets or sets the unique control ID. |
attribute
static value
bindable
|
null | |
IncludeInPage | Boolean | Gets or sets whether the control is included in the DOM of the page. |
attribute
bindable
|
True | |
InnerText | String | Gets or sets the inner text of the HTML element. |
attribute
static value
bindable
|
null | |
Text | String |
attribute
static value
bindable
|
|||
Visible | Boolean | Gets or sets whether the control is visible. |
attribute
bindable
|
True |
Events
Name | Type | Description | |
---|---|---|---|
Click | Command |