Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
903
Cancel client side event if asp.net comparevalidators are not valid
posted

Is it possible to retrieve the state of comparevalidators ?

 

My UltraWebImageButton has a client side function called on click event.

It displays a "loading / please wait" pannel with ajax gif image to let the user wait while searching through the database.


Problem is that I added some CompareValidatore to validate begin and end date and they work fine. My problem is that despite the validators are not ok, the click event function is called by the ultraButton.

How can I retrieve the state of the validators inside the JScript client side function to test I need to display the loading pannel ?

Seems to be a easy question but honestly I don't have an idea on how to retrieve the state of the controls.

 

 

My client side function :

function btnRechercheJS_Click(oButton, oEvent) {
         var obj = window.document.getElementById('<%=pnlProgression.ClientID %>');
        obj.style.display = "block";

        }

 

I have tried something like :

 function btnRechercheJS_Click(oButton, oEvent) {
            var comparaisonDate1 = window.document.getElementById('<%=CompareDateDemande.ClientID %>');
            if (comparaisonDate1.IsValid)
            {
                 var obj = window.document.getElementById('<%=pnlProgression.ClientID %>');

                obj.style.display = "block";
             }
  }

Parents
No Data
Reply
  • 24497
    Verified Answer
    posted

    Hi Yannick,

    To learn about architecture of validators, I suggest you to drop on temporary page textbox (or few of them) and validator (or few of them) and run it in debug mode. Find and open "Page_Validator..." (embedded) script within Script Documents or similar option available in VisualStudio Debug->Windows, and look at content of that file.

    You probably will find following objects which can be useful for you. Particularly Page_IsValid, Page_Validators, etc. You also may set break points at various places and check how validators work.

    To get acces to (all) validators, you may do something like

    if(typeof Page_Validators != 'object')
       return;
    var vals = Page_Validators;
    for(var i = 0; i < vals.length; i++)
    {
       var val = vals[i];
       alert('id=' + val.id + ' valid=' + val.isvalid + ' text=' + val.innerHTML + ' target=' + val.controltovalidate);
       // etc.
    }

    Hope it will help.

Children