Hi,
Just upgraded to the Premium Suite for some Xmas development work.
I have created a server-side control that renders a TreeView whose nodes are set to be populated on Callback.
On expanding the first node, I have the following error message popping up:
The target 'ctl00$ctl01$mainContentArea$treeNavigation$kbTreeView' for the callback could not be found or did not implement ICallbackEventHandler.
My server-side control is below:
[DefaultProperty("Text")] | |
[ToolboxData("<{0}:KnowledgeBaseTree runat=server></{0}:KnowledgeBaseTree>")] | |
public class KnowledgeBaseTree : WebControl, ICallbackEventHandler | |
{ | |
// ... snip ... | |
protected override void CreateChildControls() | |
{ | |
// ... snip ... | |
Controls.Add(BuildContentTreeView(baseUrl,session)); | |
} | |
private RadTreeView BuildContentTreeView(string baseUrl, ISession session) | |
{ | |
// ... snip ... | |
RadTreeView radTreeView = new RadTreeView(); | |
radTreeView.NodeExpand += new RadTreeViewEventHandler(radTreeView_NodeExpand); | |
radTreeView.ID = "kbTreeView"; | |
IPost[] posts = _cachedBinder.GetRootPosts(null, TimeSpan.Zero); | |
foreach (IPost post in posts) | |
{ | |
// ... snip ... | |
RadTreeNode radTreeNode = new RadTreeNode(post.Title, post.ID.ToString(), postUrl + ".aspx"); | |
} | |
return radTreeView; | |
} | |
void radTreeView_NodeExpand(object sender, RadTreeNodeEventArgs e) | |
{ | |
Guid postId = new Guid(e.Node.Value); | |
// ... snip ... | |
// get child nodes | |
IPost[] childPosts = selectedPost.GetChildPosts(null, TimeSpan.Zero); | |
foreach (IPost childPost in childPosts) | |
{ | |
string childPostUrl = Path.Combine(basePostUrl, childPost.UrlKey); | |
RadTreeNode childTreeNode = new RadTreeNode(childPost.Title, childPost.ID.ToString(), childPostUrl + ".aspx"); | |
childTreeNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack; | |
childTreeNode.Nodes.Add(childTreeNode); | |
} | |
} | |
} | |
The serverside control KnwoeldgeBaseTree (represented by the class above) is within the Page as usual:
<KB:KnowledgeBaseTree id="knowledgeBaseTree" runat="server" />
So, as far as I know, I'm in the right place as far as the page lifecycle is concerned.
I've also tried rendering the tree in the Init stage of the server control. No change.
Can you please help me fix this?