Skip to main content
.NET 8.0+

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

RuleBaseAttribute.TargetContextIDs Property

Specifies a context for checking the current Rule.

Namespace: DevExpress.Persistent.Validation

Assembly: DevExpress.Persistent.Base.v24.2.dll

#Declaration

public string TargetContextIDs { get; set; }

#Property Value

Type Description
String

A string representing a list of identifiers of the contexts when the current rule should be checked.

#Remarks

When defining a rule via a validation attribute, you should specify the contexts when this rule will be checked. For this purpose, pass a string containing a list of context identifiers separated by semicolons as the targetContextIDs parameter. A context identifier can be represented by any string value. To associate a context identifier with a particular Action, set it for the ValidationContexts property of the Application Model‘s ActionDesign | Actions | <Action> node. Via this property, you can associate any number of context identifiers with one Action, by listing them, separated by semicolons.

In addition to the Action-associated contexts, you can use predefined contexts represented by the DefaultContexts.Save and DefaultContexts.Delete enumeration values. The Save context occurs when data is committed to the database (see BaseObjectSpace.CommitChanges). The Delete context occurs when an object is deleted from the database (see BaseObjectSpace.Delete).

The contexts specified for a validation rule in code are set for the TargetContextIDs property of the IModelRuleBase node. So, you can customize the context identifiers list directly in the Application Model.

Note

You can specify an additional contextual criteria for a rule. If this criteria is satisfied by the validated object or property, the rule is checked. To do this, use RuleBaseAttribute.TargetCriteria.

#Implements

See Also