This is a migrated thread and some comments may be shown as answers.

ExpandMode="ServerSideCallBack" and "Script control is not a registered script control" error

1 Answer 59 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 08 Apr 2012, 03:08 PM
Hi

I'm experiencing a problem with RadTreeView when NodeTemplate has got a RadGrid inside of it. This generally works correct, but when ExpandMode="ServerSideCallBack" is used for node it gives an error message on expand, saying:

Script control 'testGrid' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
Parameter name: scriptControl


This simple test page shows the problem for me:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestGridInTree.aspx.cs" Inherits="TestGridInTree" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
</head>
<body>
<script type="text/javascript" language="javascript">
    AddServerNode = function (name, serverId) {
        treeView = $find("<%= TestTree.ClientID %>");
        treeView.trackChanges();
 
        var node = new Telerik.Web.UI.RadTreeNode();
 
        node.set_text(name);
 
        node.set_expandMode(Telerik.Web.UI.TreeNodeExpandMode.ServerSideCallBack);
 
        treeView.get_nodes().add(node);
 
        treeView.commitChanges();
    }
</script>
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <asp:Button runat="server" ID="btnAdd" Text="Add" OnClientClick="AddServerNode('client');return false;" />
        <Telerik:RadTreeView runat="server" ID="TestTree" OnNodeExpand="TestTree_NodeExpand">
            <NodeTemplate>
                <asp:Label runat="server" ID="lblTest" Text="test" />
                <telerik:RadGrid runat="server" ID="testGird" />
            </NodeTemplate>
 
            <Nodes>
                <telerik:RadTreeNode runat="server" ID="node1" Text="ClientSide" ExpandMode="ServerSide"/>
                <telerik:RadTreeNode runat="server" ID="node2" Text="ServerSideCallBack" ExpandMode="ServerSideCallBack" />
            </Nodes>
        </Telerik:RadTreeView>
     
    </div>
    </form>
</body>
</html>

Codebehind:
using Telerik.Web.UI;
 
public partial class TestGridInTree : System.Web.UI.Page
{
    protected void TestTree_NodeExpand(object sender, RadTreeNodeEventArgs e)
    {
        var node = new RadTreeNode("childnode");
        e.Node.Nodes.Add(node);
    }
}


In case there is a workaround for this - please note that I would like this to work for client-side added node also (Add button in sample above).

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 11 Apr 2012, 08:40 AM
Hello Alexander,

The desired functionality is not supported from the Ajax Framework itself. When you make a callback to the server you could not load server controls as the RadGrid or any other control. This is caused by the fact that when you make callback a significant portion of the page life cycle is skipped and the RadGrid could not be initialized properly. Here is a thread discussing the difference between callback and regular post back. For your scenario you should use the ServerSide expand mode.

Kind regards,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TreeView
Asked by
Alexander
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or