- 注册时间
- 2016-10-19
- 最后登录
- 1970-1-1
- 阅读权限
- 10
- 积分
- 157
- 精华
- 0
- 帖子
- 45
|
- 前端代码
- <div id="GetMenu" class="mini-datagrid" style="width: 100%;" url="/Ashx/SysMenu/test.aspx?method=GetMenuList" idfield="id">
- <div property="columns">
- <div field="Menu_Name" width="60" headeralign="center" allowsort="true">菜单名称</div>
- <div field="Menu_Img" width="15" allowsort="true" renderer="onGenderRenderer" align="center" headeralign="center">图标</div>
- <div field="Menu_Type" width="15" allowsort="true" headeralign="center">类型</div>
- <div field="birthday" width="25" headeralign="center" allowsort="true">连接目标</div>
- <div field="educational" width="25" headeralign="center">显示顺序</div>
- <div field="NavigateUrl" width="200" headeralign="center">连接地址</div>
- </div>
- </div>
复制代码 ashx代码 开始以为自己写的有问题,直接把DEMO的搬过来还是不执行
- public void ProcessRequest(HttpContext context)
- {
- context.Response.ContentType = "text/plain";
- String name = context.Request["name"];
- String methodName = context.Request["method"];
- Type type = this.GetType();
- MethodInfo method = type.GetMethod(methodName);
-
- if (method == null) throw new Exception("method is null");
- try
- {
- method.Invoke(this, null);
- }
- catch (Exception ex)
- {
- Hashtable result = new Hashtable();
- result["error"] = -1;
- result["message"] = ex.Message;
- result["stackTrace"] = ex.StackTrace;
- String json = JSON.Encode(result);
- Response.Clear();
- Response.Write(json);
- }
- }
- Base_SystemBLL sysbll = new Base_SystemBLL();
- public void GetMenuList()
- {
- String id = Request["id"];
- Hashtable result = sysbll.GetMenuList();
- String json = JSON.Encode(result);
- Response.Write(json);
- }
复制代码 替换成aspx执行没有问题,直接显示数据了。但是ASHX怎么整都不现实数据
下面是aspx页面代码可以正常显示数据
- protected void Page_Load(object sender, EventArgs e)
- {
- String methodName = Request["method"];
- Type type = this.GetType();
- MethodInfo method = type.GetMethod(methodName);
- if (method == null) throw new Exception("method is null");
- try
- {
- method.Invoke(this, null);
- }
- catch (Exception ex)
- {
- Hashtable result = new Hashtable();
- result["error"] = -1;
- result["message"] = ex.Message;
- result["stackTrace"] = ex.StackTrace;
- String json = JSON.Encode(result);
- Response.Clear();
- Response.Write(json);
- }
- }
- Base_SystemBLL sysbll = new Base_SystemBLL();
- public void GetMenuList()
- {
- String id = Request["id"];
- Hashtable result = sysbll.GetMenuList();
- String json = JSON.Encode(result);
- Response.Write(json);
- }
复制代码 老大 帮看看那里有错。还是我的写法不对
|
|