Monday, July 16, 2012

Asp.Net jQuery UI Autocomplete Delay


In this post Asp.Net jQuery UI Autocomplete Delay we shall see on how to use the Delay property to control the display of the Autocomplete control.

The Delay property determines the display timing of the Autocomplete options, we can set the number of milliseconds by which the display should be delayed after the user enters text using the following script.


Create an .aspx page, add a TextBox to the page and add the below jQuery script. Change the references of the jQuery library files to map to your local path. Build and run the application. Notice that the Autocomplete options are displayed after 1 second.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>jQuery UI Autocomplete </title>
    <link type="text/css"
href="css/smoothness/jquery-ui-1.8.21.custom.css"
rel="Stylesheet" />
    <script
type="text/javascript"
src="JavaScript/jquery-1.7.2.js"></script>
    <script
type="text/javascript"
src="JavaScript/jquery-ui-1.8.21.custom.min.js"></script>
    <link
type="text/css"
href="Stylesheet.css" // Add your own .css file (Optional)
rel="Stylesheet" />
<script type="text/javascript">
        var arrCountries = [
                  "Albania",
                  "Algeria",
                  "Andorra",
                  "Angola",
                  "Anguilla",
                  "Antarctica",
                  "Argentina",
                  "Armenia",
                  "Aruba",
                  "Australia",
                  "Azerbaijan"
          ];
        //
$(document).ready(function() {
            //
            // AutoComplete Delay (Default 1000)
            $("#txtAutocompleteDelay").autocomplete
            ({
                source: arrCountries,
                delay: 1000
            });
});
</script>
</head>
<body>
    <form id=" frmAutocompleterunat="server">
        <table>
            <tr>
                <td>Autocomplete delay: </td>
                <td>
                    <asp:TextBox
                        ID="txtAutocompleteDelay"
                        runat="server"></asp:TextBox>
                </td>               
            </tr>  
  </table>
    </form>
</body>
</html>

For a full example covering all possible scenarios in using a jQuery UI Autocomplete control refer to the post Asp.net jQuery UI Autocomplete Tutorial

Related Posts


Search Flipkart Products:
Flipkart.com

No comments: