SIGN UP MEMBER LOGIN:    
ARTICLE

AutoComplete using JQuery

Posted by Raj Kumar Articles | ASP.NET Programming January 31, 2011
This sample demonstrates how to use AutoComplete functionality using JQuery.
Reader Level:
Download Files:
 

This sample demonstrates how to use AutoComplete functionality using JQuery. AutoComplete is used to like popup panel to display words that has the prefix typed into textbox.

Getting Started

Creating a ASP.NET Application:

  • Open VisualStudio 2010.
  • Go to File =>New => Web Site.
  • Select ASP.NETWeb Site from the Installed templates
  • Enter the Nameand choose the location.
  • Click OK.

Now on page first of all add these .js files inside of head tag.

<title>jQuery Autocomplete Sample</title>
        <link rel="stylesheet" href="theme/jquery.ui.all.css">
        <script src="jquery-1.4.4.js"></script>
        <script src="ui/jquery.ui.core.js"></script>
        <script src="ui/jquery.ui.widget.js"></script>
        <script src="ui/jquery.ui.position.js"></script>
        <script src="ui/jquery.ui.autocomplete.js"></script>

<script>
            $(function () {
                var technologies = [
                        "ActiveDirectory",
                        "ADO.NET",
                        "AJAX",
                        "Algorithms",
                        "ASP.NET",
                        "ASP.NET MVC",
                        "Assemblies",
                        "BizTalk Server",
                        "C#",
                        "Career Advice",
                        "Cloud Computing",
                        "COBOL.NET",
                        "Compact Framework",
                        "Deployment",
                        "DirectX",
                        "Enterprise Development",
                        "Exception Handling",
                        "Financial Applications",
                        "Games Programming",
                        "Hardware",
                        "HTML",
                        "JQuery",
            "LINQ",
            "MESSAGE QUEUE",
            "Mobile EMBEDDED",
            "Networking",
            "Pocket PC",
            "Printing",
            "Project Management",
            "Remoting",
            "Sharepoint",
            "Silverligh",
            "Testing",
            "Threading",
            "WCF",
            "Web Forms",
            "Web Services",
            "WF",
            "Windows Phone"
                ];
                $("#tags").autocomplete({
                    source: technologies
                });
            });
        </script>
    <style type="text/css">
        #tags {
            width: 249px;
        }
    </style>

Now add a INPUT html control inside of form tag.

<div class="demo">
    <div class="ui-widget">
        <label for="tags">Technologies: </label>
        <input id="tags"
            style="font-family: 'Cordia New'; font-size: x-large; font-weight: normal; font-style: italic; font-variant: normal; color: #FF0000" />
    </div>
    </div>   

This is it. Now time to run the application to see the result.

 

img1.jpg

Figure 1.

 

img2.jpg

Figure 2.


img3.jpg

Figure 3.


All .js and .css files are in attached application.

This is it. If you have any question or comments then drop me a line in c-sharpcorner comments section.

Login to add your contents and source code to this article
share this article :
post comment
 

you are right hassan. there is one more way use Ajax AutoComplete extender. http://www.c-sharpcorner.com/UploadFile/raj1979/AutoComplete02142008113654AM/AutoComplete.aspx http://www.c-sharpcorner.com/UploadFile/dpatra/247/

Posted by Raj Kumar Feb 01, 2011

this is one way of doing it , another way could be my making an async call to a service which returns the xml that can be binded to the variable.

Posted by Hassan Humayun Feb 01, 2011
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor