Click here to Skip to main content
Click here to Skip to main content
Go to top

Custom ASP.NET DropdownList Control Using Chosen jQuery Plugin

, 16 Aug 2013
Rate this:
Please Sign up or sign in to vote.
Custom ASP.NET DropdownList control using chosen jQuery plugin

Introduction

The ASP.NET DropDownList is an easy way to offer a set of selections for the user. However, if you want to allow the user to enter information not available in the dropdown list, you will have to write your own JavaScript code or jQuery. This source code combines that work into an ASP.NET DLL control you can easily place on any ASP.NET web page.

The downloadable source project above uses the following technologies:

Example

Background

You do not need to have knowledge of jQuery, JavaScript, or CSS to use the DropDownListChosen. The only requirement is to drag and drop the DropDownListChosen control. The source code download contains the class library project for the DropDownListChosen and a test website using the DropDownListChosen control.

Using the Code

To use the DropDownListChosen, you will need to follow these steps:

  1. Include a project reference to the DropDownChosen.dll to your ASP.NET webforms project.
    • You can skip steps 2 and 3 by using the DropDownListChosen from your Visual Studio toolbox.
    • To do so, be sure that you are currently editing a web page so that you can get access to the toolbox and ASP.NET controls.
    • From your Visual Studio toolbox, right click to create a new tab or use an existing one to add the DropDownListChosen. Start by right clicking in the toolbox and select "Choose Items.." and then browse to where you have saved the DropDownChosen.dll.
    • Once added, you can now double click or click and drag the DropDownListChosen to your web page to get started. This will automatically add the reference to your web project, place the proper code in the header of your web page, and add the control into your web page.
  2. Register the DropDownListChosen at the top of your web page:
    <%@ Register Assembly="DropDownChosen" 
    Namespace="CustomDropDown" TagPrefix="cc1" %> 
  3. Add the script tags for the DropDownListChosen on your web page:
    <cc1:DropDownListChosen ID="DropDownListChosen1" runat="server" 
                NoResultsText="No results match." width="350px"            
                DataPlaceHolder="Type Here..." AllowSingleDeselect="true">                
            </cc1:DropDownListChosen> 
  4. Bind items to your dropdown list either manually by adding ListItems to the DropDownListChosen or by binding to a DataSource.
    Datasource example can be found in the downloadable source code above.

You're done! You can now work with your DropDownListChosen to find what options work best for you. I would love to hear some great feedback if you use this control on your site.

History

  • 13th July, 2013: Tip published
  • 7th August, 2013: Added DataPlaceHolder property and removed style sheet that causes design problems
  • 7th September, 2013: Added new properties AllowSingleDeselect and DisableSearchThreshold

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Angel Blandón
Software Developer
Nicaragua Nicaragua
I am a ASP.Net Software Developer from Nicaragua.

Comments and Discussions

 
QuestionNice but same problem as ajax combobox Pinmemberktkiebel17-Sep-13 16:28 
QuestionSearch option not displaying Pinmemberanuexuberant11-Sep-13 2:31 
AnswerRe: Search option not displaying PinmemberAngel Blandón11-Sep-13 5:42 
QuestionSelected item not working PinmemberMember 102092289-Sep-13 5:56 
AnswerRe: Selected item not working PinmemberAngel Blandón9-Sep-13 7:27 
QuestionZIP file broken? PinmemberMember 1020758214-Aug-13 13:13 
AnswerRe: ZIP file broken? PinmemberAngel Blandón14-Aug-13 17:14 
GeneralRe: ZIP file broken? PinmemberMember 1020758215-Aug-13 5:18 
for some reason it will not open. I have tried three different browsers (IE,CHROME,Mozilla). Even on the browse code page it is showing a file error. I think the zip file is corrupt. Can you please create a new zip folder and attach the files?
GeneralRe: ZIP file broken? PinmemberMember 1020758215-Aug-13 7:05 
Questionhow to use in MVC4 PinmemberMohit Jagtap10-Aug-13 2:22 
AnswerRe: how to use in MVC4 PinmemberAngel Blandón10-Aug-13 6:13 
Questionchanging the entire page design while adding DropDownListChosen dll Pinmembershyamrashun6-Aug-13 18:52 
AnswerRe: changing the entire page design while adding DropDownListChosen dll PinmemberAngel Blandón7-Aug-13 4:07 
GeneralRe: changing the entire page design while adding DropDownListChosen dll PinmemberMember 103280719-May-14 14:10 
QuestionLook and feel gets disturbed PinmemberMember 911410726-Jul-13 18:36 
Suggestionsource code Pinmembertechchallenger14-Jul-13 9:06 
GeneralRe: source code Pinmemberarbh8914-Jul-13 9:14 
GeneralRe: source code Pinmembertechchallenger14-Jul-13 9:19 
GeneralRe: source code PinmemberАslam Iqbal14-Jul-13 18:29 
GeneralRe: source code Pinmembertechchallenger15-Jul-13 2:13 
GeneralRe: source code PinmemberАslam Iqbal15-Jul-13 18:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140922.1 | Last Updated 16 Aug 2013
Article Copyright 2013 by Angel Blandón
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid