Bug Report B205378
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

How to correctly enable Model, Unobtrusive or jQuery Client validation

CallbackPanel - Client Validation does not work

created 14 years ago

The attached example has the following views: Index.cshtml, _cbTest.cshtml (callback panel partial), _pcTest.cshtml (popup control partial) and _test.cshtml (content of the partial). The _test is the content of _cbTest, which is the content of _pcTest.
A button on Index calls the javascript method ShowTestWindow. Within this method are two lines of code:
cbTest.PerformCallback();
pcTest.Show();
When the popup is displayed, the Name and City fields are required. When you click the save button on the popup no client side validation is fired. If you comment out the cbTestPerformCallback in the ShowTestWindow and display the popup the client side validation works as expected.
Why is the client side validation not firing if the callback performs a callback?

Show previous comments (3)
DevExpress Support Team 13 years ago

    Hello Tom:
    This problem is caused by the fact that validation scripts are not initialized on callbacks.
    You can solve it by calling the following script before the Save() method:

    JavaScript
    function PrepareValidationData(){ var form = $('#CityEditForm'); if (form.executed) return; form.removeData("validator"); $.validator.unobtrusive.parse(document); form.executed = true; }

    Attached is a project that illustrates this solution.
    Thanks
    Kate.

      Thank you. That resolved my issue. Can you please mark this as Non-Private so it can be viewed by all users. Someone else might find this useful.

      DevExpress Support Team 13 years ago

        Hello Tom:
        I am glad to hear that the issue is solved. I have marked this ticket as "Public".
        Thanks
        Kate.

        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.