Click here to Skip to main content
15,909,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi frnds,


I have a gridview. on that i have a checkbox in gridview. and i have one more button outside of gridview to delete particular selected row. I wrote some javascript function for checking the checkbox in gridview and iam calling that in onclient click event. Now i have to show confirmation message before deleting that particular row. for that one also i wrote some conformation function in javascript. how can i will call these two functions in one onclient click event.

Here is my code

JavaScript
function TestCheckBox()
   {       
   TargetBaseControl = document.getElementById('<%= this.GridView1.ClientID %>');
       
      if(TargetBaseControl == null) return false;
      
      //get target child control.
      var TargetChildControl = "CheckBox1";
            
      //get all the control of the type INPUT in the base control.
      var Inputs = TargetBaseControl.getElementsByTagName("input"); 
        var c=0;    
      for(var n = 0; n < Inputs.length; n++)
      {
     
         if(Inputs[n].type == 'checkbox' && 
            Inputs[n].id.indexOf(TargetChildControl,0) >= 0 && 
            Inputs[n].checked)
            {
               c++;
            // return true; 
            }
            
             
          }
          if(c==1)
          {
          return true;
          }
          else if(c>1)
          {
          for(var j=0;j<Inputs.length;j++)
          {
          Inputs[j].checked=false;
          }
          alert('Please select only one transaction');
          return false;
          }
          else if(c==0)
             {
          alert('Please select One transaction!');
              return false; 
            }
   }

another function is

function confirmdelete()
  {
  
  if(confirm("Are u sure delete partyhall")==true)
     return true;
     else
     return false;
  }

And my button code is

ASP.NET
<asp:Button ID="deletebtn" runat="server" Text="Delete Partyhall" BackColor="#0099FF"  Font-Bold="true" Font-Size="10pt" ForeColor="White" 
OnClientClick="javascript:return TestCheckBox();" onclick="deletebtn_Click" />
Posted
Updated 25-Jan-22 2:08am
v2

I am not sure you can try this

OnClientClick="javascript:return TestCheckBox();javascript:return confirmdelete()"
 
Share this answer
 
Comments
swarup65 14-Dec-11 0:29am    
Hi balakrishnan,

whenever i call like this it's calling the TestCheckBox() only, it's not calling confirmdelete()
var b=clientValidation();if(b) var b=ConfirmSave(this);return b
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900