Back to Devexpress

Controller.Active Property

expressappframework-devexpress-dot-expressapp-dot-controller-c7b50b4e.md

latest5.7 KB
Original Source

Controller.Active Property

Provides access to a collection of reason/value pairs used to activate or deactivate a Controller, or determine its active state.

Namespace : DevExpress.ExpressApp

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
[Browsable(false)]
public BoolList Active { get; }
vb
<Browsable(False)>
Public ReadOnly Property Active As BoolList

Property Value

TypeDescription
BoolList

A BoolList object that represents a collection of key/value elements.

|

Remarks

The decision to activate or deactivate a Controller is made based on all the collected requests. For example, the system may want to activate the Controller because the current View is appropriate. At the same time, the Security system may want to deactivate the Controller because the current User does not have the proper permissions. As a result, the Controller cannot be activated, because there is at least one reason for disallowing that. The Active property is designed to collect the reasons for activation/deactivation. It provides access to a collection of reason/value pairs. Each element of this collection is a pair consisting of a string value representing a reason for activation or deactivation and a Boolean value indicating whether to activate or deactivate the current Controller. This collection is used to determine whether the current Controller is active. The Controller is active if none of the collection items’ value part is set to false.

To determine whether a Controller is currently active, use the Active property in a conditional expression. Alternatively, use the BoolList.ResultValue property of the object returned by Active.

csharp
MyViewController myController;
//...
BoolList activeList = myController.Active;
if (activeList) {
    //...
}

To deactivate an active Controller, use the BoolList.SetItemValue method of the BoolList object returned by this property. Pass the reason for deactivation as the first parameter, and false , or a Boolean expression, as the second parameter. Alternatively, you can use the [key] operator of the BoolList object returned by the Active property, to get or set the specified key’s value.

csharp
MyViewController myController;
//...
BoolList activeList = myController.Active;
activeList["myKey"] = false;

To activate an inactive Controller, use the BoolList.RemoveItem method of the BoolList object, returned by this property. Pass the key (reason) of the item with the false value. If this is a single item that has the false value, the Controller will be activated. Alternatively, you can use the BoolList.SetItemValue method by passing the key, which has false as a value, and true as a new value for it.

csharp
MyViewController myController;
//...
BoolList activeList = myController.Active;
activeList["disablingKey"] = true;

To activate or deactivate an Action instead of the entire Controller, use the Action’s ActionBase.Active property.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Active property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

XAF_Non-Persistent-Objects-Edit-Linked-Persistent-Objects-Demo/CS/EFCore/NonPersistentEditEF/NonPersistentEditEF.Module/Controllers/ProductViewNestedCollectionController.cs#L20

csharp
if(linkUnlinkController != null) {
    linkUnlinkController.Active["NotInProductView"] = !(pcs != null && (pcs.MasterObject is ProductView));
}

See Also

Determine Why an Action, Controller or Editor is Inactive

Define the Scope of Controllers and Actions

Controller Class

Controller Members

DevExpress.ExpressApp Namespace