Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Fredrik Esseen 610 posts 906 karma points
    Oct 01, 2010 @ 16:03
    Fredrik Esseen
    0

    Create Autocomplete with custom handler

    Hi!

    Im trying to create my own autocomplete on a search field with my own custom handler.

    But I dont know if Im doing this right.

    This is the call from jquey automplete:

    $(document).ready(function () {

    $(".SearchBox").autocomplete("AutoComplete.ashx");

    });

    And this is my handler (simple so far just for testing):

    public

     

     

    class AutocompleteData : IHttpHandler

    {

     

     

    public void ProcessRequest(HttpContext context)

    {

     

     

    var specificNode = new Node(1052);

     

     

     

    var childNodes = specificNode.Children;

     

     

    string Query = context.Request.QueryString["q"];

     

     

    //Iterating over nodes collection example

     

     

    foreach (Node node in childNodes)

    {

     

     

    string strNode = node.ToString();

     

     

     

    if (strNode.IndexOf(Query) > -1)

    {

    context.Response.Write(node.Name);

    }

     

    }

    }

     

    public bool IsReusable { get { return false; } }

    }

    I've put the ashx file in the root of the website.

  • Jim C 3 posts 23 karma points
    Feb 03, 2011 @ 19:22
    Jim C
    0

    I have the same issue.

    I'm using autocomplete on a textbox, everything works fine locally with the usercontrol, but I don't know know where to put the ashx

Please Sign in or register to post replies

Write your reply to:

Draft