I have the following:
public void ProcessRequest(HttpContext context)
{
string query = context.Request.QueryString["term"];
System.Web.Script.Serialization.JavaScriptSerializer JsonSerializer =
new System.Web.Script.Serialization.JavaScriptSerializer();
List<Category> Categs = Category.getAll();
var result = from c in Categs where Categs.Contains(c.Name) select c;
context.Response.ContentType = "application/json";
context.Response.Write(JsonSerializer.Serialize(result));
}
Trying to return a list of [ { label: "Choice1", value: "value1" }, ... ] for jQuery UI autocomplete. I have Categories which have ID and Name properties and I want to filter the List based on the "term" in the querystring and Name property. How should i do that?
Thanks in advance.
JsonSerializershould bejsonSerializer,Categsshould becategs, andgetAll()should beGetAll(). Also you could avoid typing outSystem.Web.Script.Serialization.JavaScriptSerializertwice by replacing the first occurance withvar.