asp.net三级联动(jquery+json)
liandong.aspx:
------------------------------------------
为内丘等地区用户提供了全套网页设计制作服务,及内丘网站建设行业解决方案。主营业务为成都网站设计、网站制作、内丘网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="liandong.aspx.cs" Inherits="WebApplication1.liandong" %>无标题页
liandong.aspx.cs
-------------------------------------------------------------------------------------------
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; namespace WebApplication1 { public partial class liandong : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { string sql = "select * from t_ld where pid=0"; DataTable dt = DBhelper.query(sql); foreach (DataRow dr in dt.Rows) { ListItem li = new ListItem(dr["name"].ToString(), dr["id"].ToString()); this.DropDownList1.Items.Add(li); } } } } }
liandong.ashx.cs
using System; using System.Collections; using System.Data; using System.Linq; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; using System.Xml.Linq; namespace WebApplication1 { ////// $codebehindclassname$ 的摘要说明 /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class liandong1 : IHttpHandler { public void Proce***equest(HttpContext context) { context.Response.ContentType = "text/html"; if(!string.IsNullOrEmpty(context.Request.QueryString["pid"])) { int pid = Convert.ToInt32(context.Request.QueryString["pid"]); string sql = "select * from t_ld where pid=" + pid; DataTable dt = DBhelper.query(sql); string json_str = ""; json_str += "["; foreach (DataRow dr in dt.Rows) { json_str += "{\"id\""; json_str += ":"; json_str += "\"" + dr["id"].ToString() + "\""; json_str += ","; json_str += "\"name\""; json_str += ":"; json_str += "\"" + dr["name"].ToString() + "\""; json_str += "}"; json_str += ","; } json_str = json_str.Substring(0, json_str.Length - 1); json_str += "]"; context.Response.Write(json_str); } } public bool IsReusable { get { return false; } } } }
网站栏目:asp.net三级联动(jquery+json)
标题来源:http://hbruida.cn/article/gpcoeo.html