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
165
Custom validtor
posted

Hi,

I'm Using infragistics version 8.2  for framwork 3.5

How to use custom validator for webcombo in asp.net 3.5.

Thanks in advance,

 

  • 2167
    posted

    If all you are looking for is that the user types in a value = to a value in your list... 
    Use a custom validator with this as your validation function:

    function ValidateCombo(oCombo,ColIndex) {
        try {  

            var grid=oCombo.getGrid();
            var rowCount=grid.Rows.length;
            var currVal='';
            var comboText=oCombo.displayValue;

            for(i=0;i<rowCount;i++){
              var row=grid.Rows.getRow(i);
              currVal=row.getCell(ColIndex).getValue();
              if (currVal == comboText) {
                return true;
              }   
            }
            return false;
        }   
        catch ( err ) {
            var txtMessage = document.title + " - Error in ValidateCombo()\n" + err.description ;
            alert( txtMessage ) ;
        }  

    }

  • 45049
    Suggested Answer
    posted

    You can add a hidden input element to your page, update the value of that element whenever the value of the WebCombo is changed, and apply your validator against that input element.

    WebCombo cannot be directly used as the target for an ASP.NET validator.