PDA

View Full Version : Passing node from Ext.tree.TreePanel to asmx web method



ausername
29 Aug 2012, 10:32 AM
I am having a hard time getting / retrieving the node parameter and value from a treepanel and having it show up in my .asmx function in my .net C# project.

Here is the tree panel code:



var rootMenuDatabaseTables = 'SQL_Server';
var rootMenuDatabaseTablesLc = 'sql_server';

Ext.ux.TreeDatabaseTables = Ext.extend(Ext.tree.TreePanel, {
// Init the Component

initComponent:function() {
// Componet Functions used in Init process

// applyIf so we can extent this new class in the future
var Tree = Ext.tree;
var menuTreeId = Ext.id();
Ext.applyIf(this, {
id: menuTreeId,
scope: this,
//layout: 'fit',
useArrows: true,
autoScroll: true,
border: false,
animate: true,
containerScroll: true,
root: new Tree.AsyncTreeNode({
scope: this,
text: rootMenuDatabaseTables,
draggable:false,
id:rootMenuDatabaseTables
}),
loader: new Tree.TreeLoader({
url: '../BAB_Net/Service.asmx/SQlServerTableTree',
jsonData: {}
})
});
this.on('contextmenu', this.menuShow, this);
Ext.ux.TreeDatabaseTables.superclass.initComponent.apply(this, arguments);
}, // eo function initComponent

listeners : {
scope : this,
beforeload: function(loader, node) {
Ext.Ajax.defaultHeaders = { 'Content-Type': 'application/json; charset=utf-8' };
}
}, ...


Here is my asmx method


[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string SQlServerTableTree(string node)
{
string jsonTree = @"[{id:'SQL_Server', text : 'No Children', leaf : true}]";
return jsonTree;
}


I know my JSON string is correct b/c I can show it in a grid just fine. I believe the problem is in passing the node or getting the node value into my web method from this treepanel. In my firefox, firebug it shows in the post section: node=SQL_Server

This is the error I receive.

Invalid JSON primitive: node.
at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()

Any help would be great.