Ticket T705551
Visible to All Users

DateBox and ValidationSummary don't display server-side errors from ModelState

created 6 years ago (modified 6 years ago)

Hello. I have a problem using the data validation mechanism in DevExtreme 18.2.4. (MVC Core 2.2.0, Chrome Version 71.0.3578.98 (Official Build) (64-bit))

I used the ModelState mechanism to show error on the client side. It worked with the TextBox control, but it did not work for the DateBox, ValidationSummary control.

I understand that this is a client-side control, but is possible to display the error that was generated on the server side, for example using the ModelState mechanism?

Answers approved by DevExpress Support

created 6 years ago (modified 6 years ago)

Hi,

You can implement the server-side validation using the "custom" validation rule. Just set the validationCallback function as described in the Server-Side Validation documentation topic. Please review the above links and let me know your results.

Updated

Our editors should display ModelState errors out of the box. I researched this behavior and found that the following configuration doesn't work:

JavaScript
jQuery(function($){$("#devextreme1").dxDateBox({"name":"DateField","value":null,"inputAttr":{"id":"DateField"},"isValid":false,"validationError":{"message":"Error in field DateField"}});});

The issue occurs at the DateBox level and is not connected with MVC specifics. So I've created a separate report on your behalf:
DateBox doesn't display an error frame if isValid and validationError are defined on the first load

As for dxValidationSummary, currently, this component doesn't allow displaying errors that come from ModelState and displays only errors that occur on the client side.

    Comments (3)
    PZ PZ
    Paweł Zielski 6 years ago

      I understand.

      Can you check why in this example in the attachment dxTest.zip, the validation with the ModelState object works for the TextBox control, and does not work for the DateBox control, ValidationSummary?

      DevExpress Support Team 6 years ago

        Just wanted to drop you a note to let you know that we need a bit more time to finish working on our answer to your inquiry.  Thanks so much for your patience.

        Artem (DevExpress Support) 6 years ago

          Hi Pawel,

          Our editors should display ModelState errors out of the box. I researched this behavior and found that the following configuration doesn't work:

          JavaScript
          jQuery(function($){$("#devextreme1").dxDateBox({"name":"DateField","value":null,"inputAttr":{"id":"DateField"},"isValid":false,"validationError":{"message":"Error in field DateField"}});});

          The issue occurs at the DateBox level and is not connected with MVC specifics. So I've created a separate report on your behalf:
          DateBox doesn't display an error frame if isValid and validationError are defined on the first load

          As for dxValidationSummary, currently, this component doesn't allow displaying errors that come from ModelState and displays only errors that occur on the client side.
          There is no API to manually add these errors either.

          Let us know if you have additional questions.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.