Hi,
I have a dynamic created treeview, each node contains several kinds of user controls. My problem is I can find the "radtextbox" user
control, but I can't find the "checkbox" user control using clientside javascript.
class GrandChildNodeTemplate :ITemplate
{ ...
public void InstantiateIn(Control container)
{
cb.ID = "cb";
cb.Visible = false;
cb.DataBinding += new EventHandler(checkBox_DataBinding);
container.Controls.Add(cb);
rtb.ID = "rtb";
rtb.Visible = false;
rtb.DataBinding += new EventHandler(radTextBox_DataBinding);
container.Controls.Add(rtb);
}
}
page_load
protected void populate(RadTreeNode eNode)
{
GrandChildNodeTemplate grandChildTemplate = new GrandChildNodeTemplate();
RadTreeNode node = new RadTreeNode("gcn");
eNode.Nodes.Add(node);
grandChildTemplate.InstantiateIn(node);
....
cb = (CheckBox)node.FindControl("cb");
cb.Visible = true;
node.Value = thisGuid;
cb.Attributes.Add("onClick", "return findNode('" + thisGuid+ "')");
}
code for clientside
JS += "function findNode(args) { ";
JS += " var tv = $find('"+ rtvReportComponents.ClientID + "'); ";
JS += " var node = tv.findNodeByValue(args);";
JS += " var rtb = node.findControl(\"rtb\"); ";
JS += " if (rtb==null) alert('hello');";
JS += " var cb = node.findControl(\"cb\"); ";
JS += " if (cb==null) alert(args);"; // <--- problem is here. cb==null, can't find checkbox
JS += " if (!cb.checked){";
JS += " rtb.disable();}";
JS += " else{";
JS += " rtb.enable();}";
JS += " }";
ScriptManager.RegisterClientScriptBlock(this, GetType(), "Condition Info", JS, true);
My suspicion is node.findcontrol method can't find the DOM element? Thanks