在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
几点说明
主要代码
IDE: VS 2010 SP1 ExtJS 版本:3.4.0 参考文档:http://docs.sencha.com/ext-js/3-4/#!/api
new Ext.data.JsonStore({ // store configs autoDestroy: true, storeId: 'store', // reader configs idProperty: 'id', fields: ['id', 'title'] }); Ext.Ajax.request({ url: 'WebForm1.aspx', success: function (response, options) { var storeJson = Ext.decode(response.responseText); store.loadData(storeJson); } }); // Grid var grid = new Ext.grid.GridPanel({ renderTo: document.body, title: 'Move Database', height: 200, width: 500, store: store, columns: [ { header: "Id", dataIndex: 'id' }, { header: "Title", dataIndex: 'title' } ] }); }); </script> class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { User user = new User(); user.success = true; user.id = 1; user.title = "title"; //JavaScriptSerializer类在System.Web.Extensions.dll中,注意添加这个引用 JavaScriptSerializer serializer = new JavaScriptSerializer(); //JSON序列化 string result = serializer.Serialize(user); Response.Write(result); } } public class User { private bool _success; public bool success { get { return _success; } set { _success = value; } } private int _id; public int id { get { return _id; } set { _id = value; } } private string _title; public string title { get { return _title; } set { _title = value; } } } 说明:
结果页面
测试浏览器:Opera 11 改变后台中给User实例赋予的值 |
请发表评论