Friday, 19 October 2012

check all checkbox in gridview from javascript in asp.net c#

    <script type="text/javascript">

       
    function TestCheckBox()
   {             
     // if(TargetBaseControl == null) return false;
      TargetBaseControl = document.getElementById('<%= this.grdChqVerify.ClientID %>');
          
     
      //get target child control.
      var TargetChildControl = "chkOne";
           
      //get all the control of the type INPUT in the base control.
      var Inputs = TargetBaseControl.getElementsByTagName("input");
           
      for(var n = 0; n < Inputs.length; ++n)
         if(Inputs[n].type == 'checkbox' &&
            Inputs[n].id.indexOf(TargetChildControl,0) >= 0 &&
            Inputs[n].checked)
            {
              
          return confirm("Do you really want to update selected bills !!!");
          return true;  
          }
      alert('Select at least one checkbox!');
      return false;
   }
    </script>

No comments:

Post a Comment