Asp.net 访问aspx.cs页面';gridpanel存储中用于在extjs中获取数据的s方法

Asp.net 访问aspx.cs页面';gridpanel存储中用于在extjs中获取数据的s方法,asp.net,extjs,grid,json.net,Asp.net,Extjs,Grid,Json.net,我正在使用ExtJs 4.0。我想访问aspx.cs page方法以获取ExtJs gridpanel中的数据。 我试图从下面的代码中找到解决方案,但没有成功 grid.js Ext.application({ launch: function() { // Model definition and remote store (used Ext examples data) Ext.define('ForumThread', { e

我正在使用ExtJs 4.0。我想访问aspx.cs page方法以获取ExtJs gridpanel中的数据。 我试图从下面的代码中找到解决方案,但没有成功

grid.js

Ext.application({
    launch: function() {
        // Model definition and remote store (used Ext examples data)
        Ext.define('ForumThread', {
            extend: 'Ext.data.Model',
            fields: ['countryId', 'countryName'],
            idProperty: 'countryId'
        });

         var store = Ext.create('Ext.data.Store', {
        pageSize: 20,
        model: 'ForumThread',
        autoLoad: true,
        proxy: {
            type: 'ajax',
            url: 'mindbody.reports/test.aspx/display',
            reader: {                
                type: 'json',
                method: "GET",
                totalProperty: 'totalCount'
            }
        }
    });

        // Define grid that will automatically restore its selection after store reload
        Ext.define('PersistantSelectionGridPanel', {
            extend: 'Ext.grid.Panel',

        });

        // Create instance of previously defined persistant selection grid panel
        var grid = Ext.create('PersistantSelectionGridPanel', {
            autoscroll: true,
            height: 300,
            renderTo: Ext.getBody(),
            //region: 'center',
            store: store,
            multiSelect: true, // Delete this if you only need single row selection
            stateful: true,
            forceFit: true,
            loadMask: false,
            viewConfig: {
                stripeRows: true
            },
            columns:[{
                id: 'countryId',
                text: "countryId",
                dataIndex: 'countryId',
                flex: 1,
                sortable: false
            },{
                text: "countryName",
                dataIndex: 'countryName',
                width: 70,
                align: 'right',
                sortable: true
            } ]
        });
    }
});
public string display()
{
      country obj = new country();
      JavaScriptSerializer serializer = new JavaScriptSerializer();
      return serializer.Serialize(obj.SelectAll());  
}
test.aspx.cs

Ext.application({
    launch: function() {
        // Model definition and remote store (used Ext examples data)
        Ext.define('ForumThread', {
            extend: 'Ext.data.Model',
            fields: ['countryId', 'countryName'],
            idProperty: 'countryId'
        });

         var store = Ext.create('Ext.data.Store', {
        pageSize: 20,
        model: 'ForumThread',
        autoLoad: true,
        proxy: {
            type: 'ajax',
            url: 'mindbody.reports/test.aspx/display',
            reader: {                
                type: 'json',
                method: "GET",
                totalProperty: 'totalCount'
            }
        }
    });

        // Define grid that will automatically restore its selection after store reload
        Ext.define('PersistantSelectionGridPanel', {
            extend: 'Ext.grid.Panel',

        });

        // Create instance of previously defined persistant selection grid panel
        var grid = Ext.create('PersistantSelectionGridPanel', {
            autoscroll: true,
            height: 300,
            renderTo: Ext.getBody(),
            //region: 'center',
            store: store,
            multiSelect: true, // Delete this if you only need single row selection
            stateful: true,
            forceFit: true,
            loadMask: false,
            viewConfig: {
                stripeRows: true
            },
            columns:[{
                id: 'countryId',
                text: "countryId",
                dataIndex: 'countryId',
                flex: 1,
                sortable: false
            },{
                text: "countryName",
                dataIndex: 'countryName',
                width: 70,
                align: 'right',
                sortable: true
            } ]
        });
    }
});
public string display()
{
      country obj = new country();
      JavaScriptSerializer serializer = new JavaScriptSerializer();
      return serializer.Serialize(obj.SelectAll());  
}

url:'mindbody.reports/test.aspx/display'我试图从test.aspx页面的显示方法获取数据,但没有获取任何数据,甚至没有错误。我发现调用方法有任何错误。

在test.aspx.cs页面上的方法display()之前添加下面的代码行

  [System.Web.Services.WebMethod()]

你错过了什么。无法从浏览器中调用页面的方法。改用web服务(.asmx)。@Alexey Solonets我可以从浏览器访问类的方法吗??