Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear sir,
i am checked 5 checkBox out of 10 then how to get there id whene i am click on Button....
plz help...
Posted

You can iterate through on server side on your controls and check if the actual checkbox checked or not.

C#
//your button click function
List<string> yourIds = new List<string>();
CheckBox cb;

foreach (object actualObject in Controls)
{
    if (actualObject.GetType() == typeof(CheckBox))
    {
       cb = actualObject as CheckBox;

       if (cb.Checked)
           yourIds.Add(cb.ID);
    }
}


You can do this on client side as well.
 
Share this answer
 
v3
Comments
Rajkumar_007 26-Mar-14 2:35am    
but how to print this id's....
try this.. :)


C#
$('input:checkbox.class').each(function () {
       var sThisVal = (this.checked ? $(this).val() : "");
  });
 
Share this answer
 
 
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