Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# jsTree 3.0.2-如何将参数传递给aspx webmethod_C#_Asp.net_Web Services_Jstree - Fatal编程技术网

C# jsTree 3.0.2-如何将参数传递给aspx webmethod

C# jsTree 3.0.2-如何将参数传递给aspx webmethod,c#,asp.net,web-services,jstree,C#,Asp.net,Web Services,Jstree,我试图将jsTree 3.0.2中的一个参数传递给aspx页面上的web方法,但它没有命中web方法。但是,当没有参数时,它确实起作用。有人能指出我的错误吗 带参数(不工作): [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static IEnumerable<JsTreeNode> GetAll(string id) { // method does not get calle

我试图将jsTree 3.0.2中的一个参数传递给aspx页面上的web方法,但它没有命中web方法。但是,当没有参数时,它确实起作用。有人能指出我的错误吗

带参数(不工作):

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll(string id)
{
    // method does not get called
}

$("#jsTreeTest").jstree({
    "core": {
        "data": {
            "url": "MyPage.aspx/GetAll",
            "type": 'POST',
            "dataType": 'JSON',
            "contentType": 'application/json;',
            'data': function (node) {
                return { 'id': "01" };
            }
        }
    }
});
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll()
{
    // successfully calls method
}

$("#jsTreeTest").jstree({
    "core": {
        "data": {
            "url": "MyPage.aspx/GetAll",
            "type": 'POST',
            "dataType": 'JSON',
            "contentType": 'application/json;',
            "data": function (node) { return {}; }
        }
    }
});
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll(string id)
{
    // success!
}

$("#jsTreeTest").jstree({
    "core": {
        "data": {
            "url": "MyPage.aspx/GetAll",
            "type": 'POST',
            "dataType": 'JSON',
            "contentType": 'application/json;',
            "data": function (node) {
                return '{ "id" : "01" }';
            }
        }
    }
});
[WebMethod]
[ScriptMethod(ResponseFormat=ResponseFormat.Json)]
公共静态IEnumerable GetAll(字符串id)
{
//方法未被调用
}
$(“#jsTreeTest”).jstree({
“核心”:{
“数据”:{
“url”:“MyPage.aspx/GetAll”,
“类型”:“职位”,
“数据类型”:“JSON”,
“contentType”:“application/json;”,
“数据”:函数(节点){
返回{'id':“01”};
}
}
}
});
无参数(工作):

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll(string id)
{
    // method does not get called
}

$("#jsTreeTest").jstree({
    "core": {
        "data": {
            "url": "MyPage.aspx/GetAll",
            "type": 'POST',
            "dataType": 'JSON',
            "contentType": 'application/json;',
            'data': function (node) {
                return { 'id': "01" };
            }
        }
    }
});
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll()
{
    // successfully calls method
}

$("#jsTreeTest").jstree({
    "core": {
        "data": {
            "url": "MyPage.aspx/GetAll",
            "type": 'POST',
            "dataType": 'JSON',
            "contentType": 'application/json;',
            "data": function (node) { return {}; }
        }
    }
});
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll(string id)
{
    // success!
}

$("#jsTreeTest").jstree({
    "core": {
        "data": {
            "url": "MyPage.aspx/GetAll",
            "type": 'POST',
            "dataType": 'JSON',
            "contentType": 'application/json;',
            "data": function (node) {
                return '{ "id" : "01" }';
            }
        }
    }
});
[WebMethod]
[ScriptMethod(ResponseFormat=ResponseFormat.Json)]
公共静态IEnumerable GetAll()
{
//成功调用方法
}
$(“#jsTreeTest”).jstree({
“核心”:{
“数据”:{
“url”:“MyPage.aspx/GetAll”,
“类型”:“职位”,
“数据类型”:“JSON”,
“contentType”:“application/json;”,
“数据”:函数(节点){return{};}
}
}
});

谢谢。

找到了问题。应该是:

return '{ "id" : "01" }';
工作代码:

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll(string id)
{
    // method does not get called
}

$("#jsTreeTest").jstree({
    "core": {
        "data": {
            "url": "MyPage.aspx/GetAll",
            "type": 'POST',
            "dataType": 'JSON',
            "contentType": 'application/json;',
            'data': function (node) {
                return { 'id': "01" };
            }
        }
    }
});
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll()
{
    // successfully calls method
}

$("#jsTreeTest").jstree({
    "core": {
        "data": {
            "url": "MyPage.aspx/GetAll",
            "type": 'POST',
            "dataType": 'JSON',
            "contentType": 'application/json;',
            "data": function (node) { return {}; }
        }
    }
});
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll(string id)
{
    // success!
}

$("#jsTreeTest").jstree({
    "core": {
        "data": {
            "url": "MyPage.aspx/GetAll",
            "type": 'POST',
            "dataType": 'JSON',
            "contentType": 'application/json;',
            "data": function (node) {
                return '{ "id" : "01" }';
            }
        }
    }
});
[WebMethod]
[ScriptMethod(ResponseFormat=ResponseFormat.Json)]
公共静态IEnumerable GetAll(字符串id)
{
//成功!
}
$(“#jsTreeTest”).jstree({
“核心”:{
“数据”:{
“url”:“MyPage.aspx/GetAll”,
“类型”:“职位”,
“数据类型”:“JSON”,
“contentType”:“application/json;”,
“数据”:功能(节点){
返回“{”id:“01”}”;
}
}
}
});