home   documentation   download   contact us

How to add AutoSuggestBox to your ASP.NET project

Download and add required files
  1. Download "AutoSuggestBox" control from here
  2. Unzip the file into a directory on your system
  3. Open new or already existing web application in Visual Studio .NET
  4. Add reference to "AutoSuggestBox.dll"
    1. Right click on the project in Solution Explorer and select "Add Reference"
    2. Click on 'Browse' button in the top right corner
    3. Goto directory where you unzipped the files, select "AutoSuggestBox.dll" and click "Open"
    4. AutoSuggestBox should now appear in the references folder of your project
  5. Copy AutoSuggestBox resource files into your project
    1. Run 'Windows Explorer' and open the directory where you unzipped the files in step 2
    2. Right-click on sub directory 'asb_includes' and select 'copy'
    3. Switch back to Visual Studio
    4. Right-click on the web project in 'Solution Explorer' and select 'paste'.
    5. You should see 'asb_includes' sub-directory appear in your web project.
      The sub-directory should contain AutoSuggestBox.css, AutoSuggestBox.js, Blank.html and GetAutoSuggestData.aspx

Specify available data types
When user starts typing in AutoSuggestBox you need to provide a data source for suggested values. The system allows for as many data source as required by your application. For example you can have one data source for 'City' suggest box, another for 'Airport'.

To add data source please follow these steps:
  1. Open /AutoSuggestBox/GetAutoSuggestData.aspx.cs (or '.aspx.vb' if using VB.NET)
    NOTE: The ASPX portion of the file is empty.
  2. Scroll to the bottom of the file, where you will find function
    private ArrayList LoadMenuItems()'
  3. By default the function contains implementation of "City" datasource
  4. You can remove "city" implementation and replace it with your own
  5. If you need to add other data sources, just add more case statements to LoadMenuItems function

Add AutoSuggestBox control to a web form
  1. Create or open already existing web form
  2. Add the following line to the top of your ASPX page:
    <%@ Register TagPrefix="Custom" Namespace="ASB" Assembly="AutoSuggestBox" %>
  3. Add the following line to location where you want suggest box to appear
    <Custom:AutoSuggestBox id="Control ID" DataType="Supported Data Type" runat="server" CssClass="Text Box Style" MaxLength="Max chars in TextBox" Columns="Num of visible chars"/>

    For example:
    <Custom:AutoSuggestBox id="asbCity" DataType="City" runat="server" CssClass="FormCtrlStyle" MaxLength="100" Columns="30"/>
  4. Make sure that value of DataType attribute has been implemented in 'GetAutoSuggestData.aspx.cs' See previous section.
  5. If your web application doesn't run in the root of the webserver (ex. http://localhost/WebApp), then you need to add 'ResourcesDir' attribute to autosuggestbox tag:
    <Custom:AutoSuggestBox id="asbCity" DataType="City" runat="server" CssClass="FormCtrlStyle" MaxLength="100" Columns="30" ResourcesDir="/WebApp/AutoSuggestBox"/>

    NOTE: By default the ResourcesDir is "/asb_includes".


Now build it and ENJOY!!!
If you encounter any problems please contact us here.