Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7863783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:35:36+00:00 2026-06-02T23:35:36+00:00

I have a generic handler so i can use the jquery.ui Autocomplete, but the

  • 0

I have a generic handler so i can use the jquery.ui Autocomplete, but the handler is not firing.

Heres my code:
ASPX

<%--------- -------- Autocomplete ----------- --%>
<link type="text/css" href="../css/ui-lightness/jquery.ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../js/jquery.ui.position.js"></script>
<script type="text/javascript" src="../js/jquery.ui.autocomplete.js"></script>
<link href="../css/demos.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">

    function jqueryUI_autocomplete_update_backgroundColor(textbox) {
        var loginId = $(textbox).next().val();

        if (!textbox.disabled && loginId == "")
            textbox.style.backgroundColor = "#ff9999";
        else
            textbox.style.backgroundColor = "";
    }

    $(function () {
        $("#user").autocomplete({
            source: "Handler1.ashx",
            minLength: 1,
            select: function (event, ui) {
                $(this).next().val(ui.item.id);
                $("input[id=UserId]")[0].value = ui.item.id;
                $("input[id=DisplayName]")[0].value = ui.item.value;
                jqueryUI_autocomplete_update_backgroundColor(this);
            },

            search: function (event, ui) {
                $(this).next().val('');
                $("input[id=UserId]")[0].value = '';
                $("input[id=DisplayName]")[0].value = '';
                jqueryUI_autocomplete_update_backgroundColor(this);
            }
        })

            $("#user").data("autocomplete")._renderItem = function (ul, item) 
            {
                item.label = item.label.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(this.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
                return $("<li></li>")
                .data("item.autocomplete", item)
                .append("<a>" + item.label + "</a>")
                .appendTo(ul);
            };

    });
</script>

Handler1.ashx

/// <summary>
/// Summary description for Handler1
/// </summary>
/// 
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class Handler1 : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        IList<Project_Data.User> usersList = Project_BLL.Users.ListUsers();
        var data = new List<Project_BLL.Users>();

        foreach (Project_Data.User user in usersList)
        {
            data = new List<Project_BLL.Users>{
                new Project_BLL.Users {UserId = user.Id.ToString(), DisplayName = user.Name}
            };
        }

        int limit = 10;
        if (HttpContext.Current.Request.QueryString["limit"] != null)
            limit = Convert.ToInt32(HttpContext.Current.Request.QueryString["limit"]);

        string q = "";
        if (HttpContext.Current.Request.QueryString["term"] != null)
            q = HttpContext.Current.Request.QueryString["term"];

        List<Project_BLL.Users> result = null;
        var sb = new StringBuilder();
        if (q.Trim() != "")
        {
            var query = data.Where(p => p.DisplayName.ToLower().Contains(q.ToLower()))
                .OrderBy(p => p.DisplayName);
            result = query.Take(limit).ToList();

            foreach (var item in result)
                sb.AppendFormat("{0}{1}|{2}", (sb.Length > 0 ? "\n" : ""), item.DisplayName, item.UserId);
        }

        context.Response.ContentType = "text/plan";
        context.Response.Write(JsonConvert.SerializeObject(result.Select(u => new { id = u.UserId, value = u.DisplayName }).ToList()));

    }

Webconfig

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>

    <authentication mode="Forms">
      <forms name="TestAuthCookie" loginUrl="login.aspx" timeout="1500">
      </forms>
    </authentication>

    <authorization>
      <deny users="?"/>
    </authorization>
  </system.web>

  <location path="images">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>

  <location path="App_Themes">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>

  <location path="js">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>

  <location path="css">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>

</configuration>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:35:39+00:00Added an answer on June 2, 2026 at 11:35 pm

    Try to change the Source :

     $(function () {
            $("#user").autocomplete({
                source: function(request, response) {
                    $.ajax({
                        url: "handler1.ashx",
                        data: {
                            foo: request.term
                        },
                    });
                },
    
    
                minLength: 1,
                select: function (event, ui) {
                    $(this).next().val(ui.item.id);
                    $("input[id=UserId]")[0].value = ui.item.id;
                    $("input[id=DisplayName]")[0].value = ui.item.value;
                    jqueryUI_autocomplete_update_backgroundColor(this);
                },
    

    here you can find a working example (view source)

    From JQuery site :

    Autocomplete can be customized to work with various data sources, by just specifying the source option. A data source can be:

    • an Array with local data
    • a String, specifying a URL
    • a Callback

    You have to specify a callback that make a Post / Get to your ashx.

    Here the complete reference for $.ajax

    a Callback

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading about jQuery's deferreds, but I can't quite grasp how to
I would like to use a generic error msg handler so I can GetLastError
I have generic list which must be a preserved order so I can retrieve
I have generic type that looks like: public class GenericClass<T, U> where T :
I am aware of Web Services and WCF but I have generic question with
I have a generic Collection and am trying to work out how I can
I have a fairly generic class (Record) that I have added a callback handler
I have declared a generic event handler public delegate void EventHandler(); to which I
aka, Seeking generic Error Handler (ΟΚ to use commercially) I doubt that I am
I am trying to use Generic DataContract class so that I don't have to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.