Page_ClientValidate in undefined

Total Post:183

Points:1285
C# 
 1944  View(s)
Ratings:
Rate this:

I have an asp.net user control which is plugged into both asp.net and MVC pages

When the control is on an asp.net page the client validation in it works fine but when the control is on an MVC page the following call in the js validation fails;

Page_ClientValidate('ValidationGroup');

with the error in Chrome: Object [object global] has no method 'Page_ClientValidate'

How can I get my client side validation to work on my mvc pages when the hyperlink button is clicked?

I need whatever the solution is to work across both MVC and ASP.Net as our site is a combination of the two

  1. Post:159

    Points:1117
    Re: Page_ClientValidate in undefined

    Try something like this,

    $('#Form').submit(function () {
        if (typeof (Page_ClientValidate)== 'function') {
            Page_ClientValidate();
            if (Page_IsValid== true) {
                alert('the form is valid');
            }
        } else {
            if ($(this).valid()) {
                alert('the form is valid');
            }
        }
    });

     

      Modified On Apr-07-2018 06:38:46 AM

Answer