Hello,
I am generating dynamically a template for a RadComboBox, trying to simulate the declarative sample given for treeview in combo, it works until the point where my client side script is never called when a node is selected.
Here is part of he template code where the OnClientNodeClicking value is set:
public class PageComboTemplate : ITemplate
{
public void InstantiateIn(Control container)
{
HtmlGenericControl div1 = new HtmlGenericControl("div");
div1.ID = "div1";
div1.Style.Add( HtmlTextWriterStyle.Display, "block");
RadTreeView RadTree1 = new RadTreeView();
RadTree1.ID = "RadTree1";
RadTree1.OnClientNodeClicking = "nodeClicking";
RadTree1.Skin = "Web20";
RadTree1.AllowNodeEditing = false;
RadTree1.EnableDragAndDrop = false;
RadTree1.EnableDragAndDropBetweenNodes = false;
RadTree1.MultipleSelect = false;
RadTree1.DataBinding += new EventHandler(RadTree1_DataBinding);
div1.Controls.Add(RadTree1);
container.Controls.Add(div1);
Trace2.WriteLineIf(ModuleTraceSwitch.Sw.TraceVerbose, string.Format("[V]FastAddPage PageComboTemplate InstantiateIn END container: {0}",container));
}
Then the script extirped from the sample, in my page declaratives:
...
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat=server />
<script type="text/javascript" language="javascript">
function nodeClicking(sender, args)
{
var comboBox = $find('RadComboBox1');
var node = args.get_node();
comboBox.set_text(node.get_text());
comboBox.hideDropDown();
}
function StopPropagation(e)
{
if(!e)
{
e = window.event;
}
e.cancelBubble = true;
}
</script>
<div id="centerdiv" style="margin-left:auto; margin-right:auto; width:100%">
<div id="combodiv" style="float:left; width:250px;" >
<telerik:RadComboBox ID="RadComboBox1" runat="server" Height="140px" Width="80%"
ShowToggleImage="True" Skin="Web20" style="vertical-align:middle;" >
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
<ExpandAnimation Type="OutQuart"></ExpandAnimation>
</telerik:RadComboBox>
<script type="text/javascript">
var div1 = document.getElementById("div1");
div1.onclick = StopPropagation;
</script>
</div>
...
Where ismy error ?
Do I need to use any ScriptControlBlock RadScriptBlock to have it persisted ?
Thanks for help.
CS