Switch25
Switch25 is a toggle switch control used to represent a boolean
(On / Off) state in forms. It is commonly used for enabling or disabling features
such as status flags, settings, or options.
Key Features
- Represents boolean values using a toggle switch UI
- Supports label text for better clarity
- Optional automatic form submission on value change
Properties
- Id-This ID is used to read the switch value in the controller or postback.
- Value-If set to true, the switch is rendered in the checked (On) state.
If set to false, the switch is rendered in the unchecked (Off) state.
- Label-
Text displayed next to the switch to describe its purpose.
- IsPostBack-When set to true, the form is submitted whenever the switch value changes.
By default, this value is false.
Sample Code
Switch25.Properties props = new Switch25.Properties
{
Id = "IsEnabled",
Value = Model.IsEnabled,
Label = "Enable Feature",
IsPostBack = false
};
@Switch25.GetHtml(props)
Using Direct Parameters
@Switch25.GetHtml(
"IsActive",
true,
"Is Active",
false
)