Ticket Q348884
Visible to All Users

How to implement custom validation of DevExpress ASP.NET editors

created 13 years ago

Hi there,
I need to do validation, verifying that at least one of several CheckBox controls are checked. Normally I would do with with the ASP.NET CustomValidator. What is the recommended for doing this with DevExpress?
Thanks,
Andrew

Comments (2)
DevExpress Support Team 13 years ago

    Hello Andrew,
    Thank you for contacting us.
    I believe you can handle the client-side ASPxClientEdit.Validation event and implement any necessary custom validation in the event handler. Please refer to the Validation - Inplace Validation demo for an example.
    If you have any other questions, feel free to contact us at anytime.
    Best regards,
    Vladimir

      Hi Vladimir,
      Yes this would work, but it isn't quite the correct solution. It doesn't really make sense to show the message beside any specific checkbox when it applies to all of them. It would work, yes, but it would not meet the requirement the same way that the ASP.NET CustomValidator can. Using the CustomValidator, I can put the error message anywhere on the page.
      I believe this is a feature gap between the DevExpress ASP.NET controls and the native ASP.NET validation controls.
      Perhaps I can work around this by adding a control, adding my page-wide validation logic to it, and then hiding it with CSS so that only the error message gets displayed when there's an error?
      Thanks,
      Andrew

      Answers

      created 13 years ago

      Hello Andrew,
      Thank you for your clarification.
      I believe you can utilize the ASPxValidationSummary to display a validation message at any place on a page. Please refer to the Validation - Validation Summary demo for an example.
      If it does not meet your requirements, would you demonstrate your scenario to us and we'll try to find a corresponding solution.
      Best regards,
      Vladimir

        Comments (2)

          Here is an example of probably what he is talking about:

          ASPx
          <asp:CustomValidator runat="server" Enabled="true" ID="cvSelections" Display="Dynamic" ErrorMessage="My Error message" SetFocusOnError="True" ForeColor="Red" Font-Bold="true" OnServerValidate="cvSelections_ServerValidate" />

          This obviously isn't bound to an UI control. It is just some validation.

          Do I need to start hacking? eg create a 0px wide ASPxEdit control just so I can put validation against it?

          I think this is what he meant by a feature-gap between DX controls and ASP controls.

          regards,
          -randall sell

          DevExpress Support Team 8 years ago

            Thank you for your clarification, Randal.

            In this case, I believe that you can use ASPxValidationSummary.ValidationGroup to display an error message of an editor (or editors) that has the same ASPxEdit.ValidationSettings.ValidationGroup.You can place the Validation group to any place on a page regardless of the editor's position.

            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.