Checkbox
Universal Dashboard is now a part of PowerShell Universal. This documentation is for reference to the v2 version of Universal Dashboard and is no longer maintained.
PowerShell Universal Documentation can be found here.

Checkbox

Properties

1
New-UDCheckbox -Label Unchecked
2
New-UDCheckbox -Label Checked -Checked
3
New-UDCheckbox -Label 'Filled In' -Checked -FilledIn
4
New-UDCheckbox -Label 'Disabled' -Checked -FilledIn -Disabled
Copied!

OnChange Handler

See Event Handler Endpoints for more information about how event handlers work.
To handle changes in the checkbox value, you can add a script block or UDEndpoint to the -OnChange parameter.
1
New-UDElement -Id "CheckboxState" -Tag "span"
2
New-UDCheckbox -Id CheckBox -Label "Check me" -OnChange {
3
$Element = Get-UDElement -Id CheckBox
4
Set-UDElement -Id "CheckboxState" -Content $Element.Attributes["checked"]
5
}
Copied!

Get the value of the Checkbox

To get checkbox value ($true, $false), you can utilize the Get-UDElement cmdlet to retrieve the bool checked value.
`text New-UDCheckbox -Id MyCheckBox -Label "Check me" $CheckboxValue = ((Get-UDElement -Id "MyCheckBox").Attributes["checked"])
Last modified 3mo ago