Here I have created sample that full-fill your requirement.in this on button click you will get selected child check box in Javascript as well as in code behind.
HTML
<div>
<asp:TreeView ID="TreeView1" runat="server" ShowCheckBoxes="All">
</asp:TreeView>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("[id*=TreeView1] input[type=checkbox]").bind("click", function () {
var table = $(this).closest("table");
if (table.next().length > 0 && table.next()[0].tagName == "DIV") {
//Is Parent CheckBox
var childDiv = table.next();
var isChecked = $(this).is(":checked");
$("input[type=checkbox]", childDiv).each(function () {
if (isChecked) {
$(this).attr("checked", "checked");
} else {
$(this).removeAttr("checked");
}
});
} else {
//Is Child CheckBox
var parentDIV = $(this).closest("DIV");
if ($("input[type=checkbox]", parentDIV).length == $("input[type=checkbox]:checked", parentDIV).length) {
$("input[type=checkbox]", parentDIV.prev()).attr("checked", "checked");
} else {
$("input[type=checkbox]", parentDIV.prev()).removeAttr("checked");
}
}
});
})
function GetSelected() {
var childCheckBox = '';
var parentCheckBox = '';
var chkparent = $('[alt*=Collapse]').closest('tr').find('input[type=checkbox]').next('a').each(function () {
parentCheckBox = parentCheckBox + $(this)[0].innerText + ',';
});
var chkChilds = $("input[type=checkbox]:checked").each(function () {
childCheckBox = childCheckBox + $(this).next('a')[0].innerText + ',';
});
var chkChilds = childCheckBox.substring(0, (childCheckBox.lastIndexOf(','))).split(',');
var chkparent = parentCheckBox.substring(0, (parentCheckBox.lastIndexOf(','))).split(',');
var result = $.grep(chkChilds, function (el) {
return $.inArray(el, chkparent) == -1;
});
var resultStr = result.join(',');
$('[id*=hfSelected]').val(resultStr);
alert('Selected Child : ' + resultStr);
}
</script>
<asp:Button Text="Get Selected" runat="server" OnClientClick="GetSelected()" OnClick="GetSelected" />
<input id="hfSelected" type="hidden" runat="server" />
</div>
Code
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TreeNode treeNode = new TreeNode("Fruits", "Fruits");
treeNode.ShowCheckBox = true;
TreeView1.Nodes.Add(new TreeNode("Fruits", "Fruits"));
TreeView1.Nodes[0].ChildNodes.Add(new TreeNode("Mango", "Mango"));
TreeView1.Nodes[0].ChildNodes.Add(new TreeNode("Apple", "Apple"));
TreeView1.Nodes[0].ChildNodes.Add(new TreeNode("Pineapple", "Pineapple"));
TreeView1.Nodes[0].ChildNodes.Add(new TreeNode("Orange", "Orange"));
TreeView1.Nodes[0].ChildNodes.Add(new TreeNode("Grapes", "Grapes"));
TreeView1.Nodes.Add(new TreeNode("Vegetables", "Vegetables"));
TreeView1.Nodes[1].ChildNodes.Add(new TreeNode("Carrot", "Carrot"));
TreeView1.Nodes[1].ChildNodes.Add(new TreeNode("Cauliflower", "Cauliflower"));
TreeView1.Nodes[1].ChildNodes.Add(new TreeNode("Potato", "Potato"));
TreeView1.Nodes[1].ChildNodes.Add(new TreeNode("Tomato", "Tomato"));
TreeView1.Nodes[1].ChildNodes.Add(new TreeNode("Onion", "Onion"));
}
}
protected void GetSelected(object sender, EventArgs e)
{
string seleted = hfSelected.Value;
}
Screenshot
