原创

Ext.Net 1.x_Ext.Net.Combox 实现模糊异步查询

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://david.blog.csdn.net/article/details/6121690

突然间想到百度和GOOGLE的AJAX模糊查询的功能。那就COMBOX中能不能实现呢?

查看资料

在数据源中多了一个  

            <Proxy>
                            <ext:HttpProxyMethod="POST"Url="Plants.ashx"/>
            </Proxy>

估计是异步的东东。本人才浅

先建立一个

<%@ WebHandler Language="C#" Class="DataHandler" %>

using System;
using System.Web;
using System.Collections.Generic;
using Ext.Net;
using System.Data;

public class DataHandler : IHttpHandler {
public void ProcessRequest(HttpContext context)
    {
        if (!string.IsNullOrEmpty(context.Request["query"]))
        {

            string query = context.Request["query"];

            context.Response.ContentType = "text/json";

            DataTable table = new DAL.UserDAO().WorkNoList(query).Tables[0] ;
          

            List<UserInfo> lst = new List<UserInfo>();

            foreach (DataRow row in table.Rows)
            {

                UserInfo user = new UserInfo();

                user.UserName = Convert.ToString(row["name"]);
                //user.UserId = Convert.ToInt32(row["workno"]);
                user.UserId = Convert.ToString(row["workno"]);
                lst.Add(user);

            }

            string json = Ext.Net.JSON.Serialize(lst);

            context.Response.Write(json);

        }

        else
        {

            context.Response.ContentType = "text/json";

            DataTable table = new DAL.UserDAO().WorkNoList().Tables[0] ;

            List<UserInfo> lst = new List<UserInfo>();

            foreach (DataRow row in table.Rows)
            {

                UserInfo user = new UserInfo();

                user.UserName = Convert.ToString(row["name"]);
                //user.UserId = Convert.ToInt32(row["workno"]);
                user.UserId = Convert.ToString(row["workno"]);
                lst.Add(user);

            }

            string json = Ext.Net.JSON.Serialize(lst);

            context.Response.Write(json);


        }

 

    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}

public class UserInfo
{
    private string _UserName;

    public string UserName
    {
        get { return _UserName; }
        set { _UserName = value; }
    }
    private string _UserId;

    public string  UserId
    {
        get { return _UserId; }
        set { _UserId = value; }
    }


}

 

 看看效果吧

文章最后发布于: 2011-01-07 08:04:00
展开阅读全文
0 个人打赏
私信求帮助

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 鲸 设计师: meimeiellie

分享到微信朋友圈

×

扫一扫,手机浏览