RequiredFieldValidationPattern.IsRequired Property
Gets or sets a value that specifies whether the editor is a required field.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v19.2.dll
Declaration
Property Value
Type | Default | Description |
---|---|---|
Boolean | **false** | true if the editor is a required field; otherwise, false. |
Remarks
Note
When a grid-based control is in Batch Edit mode, set the Display property to Dynamic, so as not to render the empty space (the validation error element) near the edit cell.
Web Forms:
...
<dx:GridViewDataComboBoxColumn FieldName="Answer">
<PropertiesComboBox>
...
<ValidationSettings Display="Dynamic">
<RequiredField IsRequired="true" />
</ValidationSettings>
</PropertiesComboBox>
</dx:GridViewDataComboBoxColumn>
...
MVC:
settings.CellEditorInitialize = (s, e) => {
ASPxEdit editor = (ASPxEdit)e.Editor;
editor.ValidationSettings.Display = Display.Dynamic;
};
Example
The complete sample project is available in the DevExpress Code Central database at E942.
function OnValidationCompleted(s, e) {
if(e.isValid && Password.GetValue() != ConfirmedPassword.GetValue()) {
ConfirmedPassword.SetFocus();
ErrorMessageNotEqual.SetVisible(true);
e.isValid = false;
} else
ErrorMessageNotEqual.SetVisible(false);
}
<script runat="server">
protected void Page_Load(object sender, EventArgs e) {
}
protected void ASPxGlobalEvents1_ValidationCompleted(object sender,
DevExpress.Web.ValidationCompletedEventArgs e) {
lErrorMessageNotEqual.ClientVisible
= !tbPassword.Value.Equals(tbConfirmedPassword.Value);
}
</script>
...
Type password:<br/>
<dxe:ASPxTextBox ID="tbPassword" runat="server" Width="170px"
ClientInstanceName="Password" Password="True">
<ValidationSettings SetFocusOnError="true">
<RequiredField IsRequired="True" />
</ValidationSettings>
</dxe:ASPxTextBox>
<br/>
Confirm password:
<dxe:ASPxTextBox ID="tbConfirmedPassword" runat="server" Width="170px"
ClientInstanceName="ConfirmedPassword" Password="True">
<ValidationSettings SetFocusOnError="true">
<RequiredField IsRequired="True" />
</ValidationSettings>
</dxe:ASPxTextBox>
...
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the IsRequired 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.