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

    Hi,

    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
      {
        [OperationContract()]
        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:

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

        <!-- ASP.NET compatibility mode -->
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
        
        <services>
          <!-- TreeViewService.svc -->
          <service name="TreeViewService" behaviorConfiguration="defaultBehavior">
            <host>
              <baseAddresses>
                <add baseAddress="TreeViewService.svc"/>
              </baseAddresses>
            </host>
            <endpoint address=""
                      behaviorConfiguration="ajaxBehavior"
                      binding="webHttpBinding"
                      contract="TreeViewService" />
          </service>
        </services>
        
    </system.ServiceModel>


    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" />
          <databindings>
            <telerik:RadTreeNodeBinding Depth="0" ExpandMode="WebService" ValueField="Code" />
            </databindings>
        </telerik:RadTreeView>


    What is wrong?? Thank you for help.

    Regards,
    Damjan
  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