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();
}
}