Torna al Thread

<%@ WebHandler Language="C#" Class="ajaxAutocomplete" %> using System; using System.IO; using System.Web; using System.Web.Script.Serialization; using System.Collections.Generic; using System.Runtime.Serialization.Json; using System.Text; using System.Data; using System.Linq; using System.Linq.Expressions; public class ajaxAutocomplete : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Expires = -1; string result = string.Empty; string type = context.Request["type"]; string q = string.Empty; q = context.Request.Form["term"].Trim(); JavaScriptSerializer ser = new JavaScriptSerializer(); switch (type) { case "citta": List<tipoComune> comuni = CittaProvinceNazioni.CittaProvincia(string.Empty); result = ser.Serialize(comuni.Where(item => item.Comune.ToLower().StartsWith(q.ToLower()))); break; default: break; } context.Response.ContentType = "text/plain"; context.Response.Write(result); } public bool IsReusable { get { return false; } } private void LogRequest(string Log) { //StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath("/Log") + "\\Log.txt", true); //sw.WriteLine(DateTime.Now.ToString() + " - " + Log); //sw.Flush(); //sw.Close(); } }
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5