ASPxClientEditBase.SetEnabled(value) Method
Specifies whether an editor is enabled.
Declaration
SetEnabled(
value: boolean
): void
Parameters
Name | Type | Description |
---|---|---|
value | boolean |
|
Remarks
Use the SetEnabled
method to dynamically change an editor’s ability to respond to end-user interactions (such as mouse clicks or text input). An editor’s initial availability state can be defined by using the ASPxEditBase.ClientEnabled property.
The SetEnabled
method result is not sent to the server side when a request is performed. This means that the disabled/enabled state is not synchronized with the server-side object. If you want to synchronize disabled states between client and server sides, for example, you can use the ASPxHiddenField control, containing the disabled state and restore it on the server side.
The SetEnabled
method is not in effect if an editor is initially disabled on the server by setting the Enabled
property to false
.
Important
Values of disabled inputs are not submitted.
ASPxCheckBox Example
Web Forms:
<dx:ASPxCheckBox Text="Item1" ClientInstanceName="checkBox1" ID="ASPxCheckBox1" ClientEnabled="false" runat="server">
</dx:ASPxCheckBox>
<dx:ASPxCheckBox Text="Item2" ClientInstanceName="checkBox2" ID="ASPxCheckBox2" ClientEnabled="true" runat="server">
</dx:ASPxCheckBox>
<dx:ASPxButton ID="ASPxButton2" runat="server" AutoPostBack="False" Text="Enable/Disable" Theme="Office365">
<ClientSideEvents Click="onEnableDisable" />
</dx:ASPxButton>
function onEnableDisable(s, e) {
checkBox1.SetEnabled(!checkBox1.GetEnabled());
checkBox2.SetEnabled(!checkBox2.GetEnabled());
}
MVC:
@Html.DevExpress().CheckBox(settings => {
settings.Name = "checkBox1";
settings.ClientEnabled = false;
...
}).BindList(Model.Customers).GetHtml()
@Html.DevExpress().CheckBox(settings => {
settings.Name = "checkBox2";
settings.ClientEnabled = true;
...
}).BindList(Model.Customers).GetHtml()
@Html.DevExpress().Button(settings => {
settings.Name = "button1";
settings.Text = "Enable/Disable";
settings.ClientSideEvents.Click = "onEnableDisable";
...
}).GetHtml()
function onEnableDisable(s, e) {
checkBox1.SetEnabled(!checkBox1.GetEnabled());
checkBox2.SetEnabled(!checkBox2.GetEnabled());
}
ASPxListBox Example
Web Forms:
<dx:ASPxListBox ID="ASPxListBox1" runat="server" ClientEnabled="false" ClientInstanceName="listBox"
DataSourceID="SqlDataSource3" EnableTheming="True" Theme="Office365">
<Columns>
<dx:ListBoxColumn FieldName="ProductName" Caption="Product Name" />
</Columns>
</dx:ASPxListBox>
<dx:ASPxButton ID="ASPxButton1" runat="server" AutoPostBack="False" Text="Enable/Disable" Theme="Office365">
<ClientSideEvents Click="onClick" />
</dx:ASPxButton>
function onClick(s, e) {
listBox.SetEnabled(!listBox.GetEnabled());
}
MVC:
@Html.DevExpress().ListBox(settings => {
settings.Name = "listBox";
settings.ClientEnabled = false;
...
}).BindList(Model.Customers).GetHtml()
@Html.DevExpress().Button(settings => {
settings.Name = "btnOutline";
settings.Text = "Enable/Disable";
settings.ClientSideEvents.Click = "OnClick";
...
}).GetHtml()
function OnClick(s, e, d) {
listBox.SetEnabled(!listBox.GetEnabled());
}