Skip to content

ReadOnlyWhenAttribute class

namespace: Serenity.ComponentModel   assembly: Serenity.Net.Core

Makes a field of a form read only while another field has one of the values, or has a value when none are given, e.g. [ReadOnlyWhen(nameof(IsLocked))] for while a checkbox is checked.

[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class ReadOnlyWhenAttribute : PropertyConditionAttribute
parameter description
field The name of the field whose value is checked, as the form has it, e.g. nameof(IsLocked).
values The values that make the field read only, any of which the other field can have. When there are none, it is read only while the other field has a value, i.e. it is not empty, and a checkbox while it is checked.

Public Members

name description
ReadOnlyWhenAttribute(…) Makes a field of a form read only while another field has one of the values, or has a value when none are given, e.g. [ReadOnlyWhen(nameof(IsLocked))] for while a checkbox is checked.

Remarks

A condition only makes a field read only: one that is read only, or not editable by a permission, stays so. It is for forms only, not a security boundary, which UpdatableAttribute and the permissions are.

See Also