首页 > 代码库 > asp.net 一般处理程序
asp.net 一般处理程序
一般处理程序类似公共模块,所有页面都可以调用。
一般处理程序
<%@ WebHandler Language="C#" Class="SetGrid" %>using System;using System.Web;public class SetGrid : IHttpHandler { public void ProcessRequest (HttpContext context) { string sql = ""; System.Data.DataTable dtTmp = null; string sf = ""; string result = ""; try { switch (context.Request["oper"]) { case "Supplier"://供应商 sql = "select ID,abbreviation,name,linkman1,Tel,trmo,currency,cess from provider"; if (!string.IsNullOrEmpty(context.Request["q"])) { sf = context.Request["q"].ToString().Trim(); sql += " where abbreviation like ‘%" + sf + "%‘ or linkman1 like ‘%" + sf + "%‘ or name like ‘%" + sf + "%‘ or Tel like ‘%" + sf + "%‘"; } dtTmp = pubCommon.GetDataTable(sql); result = pubCommon.DataTableToJson(dtTmp); //result = "[{\"si_name\":\"三菱\",\"si_linkman\":\"村上\",\"si_mobile\":\"12-002136\"},{\"si_name\":\"西门西\",\"si_linkman\":\"Jon\",\"si_mobile\":\"0223-26565\"}]"; break; case "PODetail": sql = "select 1 as gi_id,*,12 as pi_number,12 as qty from materiel where code = ‘110010030092‘"; dtTmp = pubCommon.GetDataTable(sql); if (dtTmp != null) { result = pubCommon.DataTableToJson(dtTmp); } break; case "Query": sql = "select * from materiel"; dtTmp = pubCommon.GetDataTable(sql); if (dtTmp != null) { result = pubCommon.DataTableToJson(dtTmp); } break; } } catch (Exception ex) { } context.Response.Write(result); context.Response.End(); } public bool IsReusable { get { return false; } }}
脚本
//供应商 $(‘#gys_key‘).combogrid({ panelWidth: 350, delay: 500, mode: ‘remote‘, idField: ‘ID‘, textField: ‘abbreviation‘, url: ‘/Project2/Dispose/SetGrid.ashx?oper=Supplier‘, columns: [[ { field: ‘abbreviation‘, title: ‘简称‘, width: 80 }, { field: ‘name‘, title: ‘供应商名称‘, width: 120 }, { field: ‘linkman1‘, title: ‘联系人‘, width: 80 }, { field: ‘Tel‘, title: ‘电话‘, width: 100 } ]], onSelect: function (rowIndex, rowData) { $("#txtTax").val(rowData.cess); $("#txtpay").val(rowData.trmo); $("#txtcurrency").val(rowData.currency); } });
asp.net 一般处理程序
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。