Similar Baidu search hint effect (ASP.NET+JQ+AJAX)

Source: Internet
Author: User

Here is the Ajax actual processing interface

<%@ WebHandler language= "C #" class= "Projectcodehandler"%> using System;
Using System.Web;
Using System.Collections.Generic;
Using AMPPROJECTMANAGER.BLL;

Using Ampprojectmanager.models; public class Projectcodehandler:ihttphandler {public void ProcessRequest (HttpContext context) {Contex
        T.response.contenttype = "Text/plain";
        String html = ""; Here, the parameter gets in the context. request.params["Methodtype"]. ToString () switch (context. request.params["Methodtype"]. ToString ()) {case ' code ': HTML = Codehandler (context. request.params["Code"].
                ToString ());
            Break
        Case "user": Break; } context.
        Response.Write (HTML); Context.
    Response.End ();
        public bool IsReusable {get {return false; } public string Codehandler (string code) {list<string> List = projectmanager.getprojectbycod Ecode);//Please interpret this as: request to the database and all data starting with the current parameter, return to string list string html = "<ul>";
        foreach (string temp in list) {html = html + "<li>" + temp + "</li>";
        HTML = html + "</ul>";
    return HTML; }
}

HTML code

<%@ Page language= "C #" autoeventwireup= "true" codefile= "Test.aspx.cs" inherits= "test"%> DOCTYPE html>  



Have a day, the effect is as follows, enter any text, the system will go into the database search, click on the selected Li, will automatically fill in the value of Li in the textbox.



The main point is two: the first JQ is linked to the database on the page, which must be Ajax, or a direct call to the existence of the page, because consider going to go to MVC, so I'll stick a link here

http://blog.csdn.net/iouxyz/article/details/5691050

There is the asp.net how to achieve Ajax, that is. ashx. All known as: General procedures for processing files.


Combined with the above can achieve results

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.