ASP.NET MVC 4使用extjs传递对象至后台方法

使用extjs创建页面,代码如下:

 buttons: [{
                        xtype: 'button',
                        text: '登录',
                        formBind: true,
                        disabled: true,
                         70,
                        height: 26,
                        handler: function () {
                            var mdl = new Object();
                            var count = Ext.getCmp('count').getValue();
                            var psw = Ext.getCmp('psw').getValue();
                            mdl.Count = count;
                            mdl.Password = psw;
                            Ext.Ajax.request({
                                url: 'Home/ValidCount',
                                params: mdl,
                                method: 'post',
                                success: function (response) {
                                    var responseArray = Ext.decode(response.responseText);
                                    alert(response.responseText);
                                },
                                failure: function () {
                                    alert('false');
                                }
                            });
                        }
                    }, {
                        xtype: 'button',
                        text: '取消',
                         70,
                        height: 26,
                        handler: function () {
                            this.up('form').getForm().reset();
                        }
                    }]

开始的时候使用mdl=[];

mdl.push({Count:count,Password:psw});没有成功,改为以上代码后成功了,

后台方法如下:

[HttpPost]
public JsonResult ValidCount(LoginMdl mdl)
{
return Json(mdl);
}

原文地址:https://www.cnblogs.com/wangq0126/p/3505015.html