TreeView load on demand (WCF): object reference not set..

2 posts, 0 answers
  1. Nejc Žerjal
    Nejc Žerjal avatar
    9 posts
    Member since:
    Nov 2009

    Posted 09 Dec 2009 Link to this post


    I use ASP.NET AJAX RadTreeView control (2009 Q3). I populate root nodes manually but for subnodes I use WCF service (to load them on demand). The problem is that the web service/method parameteres "p_Node", "p_Context" ARE ALWAYS null when method is invoked:

      [ServiceContract(Namespace = "")]
      [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
      public class TreeViewService
        public RadTreeNodeData[] LoadChildData(RadTreeNodeData p_Node, IDictionary<string, object> p_Context)
             string currentVal = p_Node.Value;  // error - null on every call
             return listOfNodes.ToArray();

    The service.model in web.config is defined as:

        <!-- bindings -->
            <binding name="webBinding">
              <security mode="None" />
        <!-- behaviors -->
            <behavior name="ajaxBehavior">
              <enableWebScript />
            <behavior name="defaultBehavior">
              <serviceDebug includeExceptionDetailInFaults="true" />
              <serviceMetadata httpGetEnabled="true" />

        <!-- ASP.NET compatibility mode -->
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
          <!-- TreeViewService.svc -->
          <service name="TreeViewService" behaviorConfiguration="defaultBehavior">
                <add baseAddress="TreeViewService.svc"/>
            <endpoint address=""
                      contract="TreeViewService" />

    The .aspx page contains the following definition:

    <telerik:RadTreeView ID="radTreeView" runat="server" OnClientNodeClicked="OnNodeClicked"
          DataFieldID="Code" EnableViewState="False" DataFieldParentID="ParentCode">
          <webservicesettings path="TreeViewService.svc" method="LoadChildData" />
            <telerik:RadTreeNodeBinding Depth="0" ExpandMode="WebService" ValueField="Code" />

    What is wrong?? Thank you for help.

  2. Vesko
    Vesko avatar
    122 posts
    Member since:
    Mar 2009

    Posted 11 Dec 2009 Link to this post

    I suggest to follow the steps from this help topic:

    WCF Web Service Load On Demand

Back to Top