Click here to Skip to main content
15,884,298 members
Articles / Web Development / ASP.NET / ASP.NET4.0
Tip/Trick

Custom ASP.NET DropdownList Control Using Chosen jQuery Plugin

Rate me:
Please Sign up or sign in to vote.
4.94/5 (20 votes)
26 Oct 2015CPOL1 min read 278.9K   7.5K   25   74
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 Nuget-Package

You can now reference this project as a nuget package.

  • Install-Package DropDownListChosen

This will add necesary configuration for you, just add the control tag to your webform like this.

ASP.NET
<asp:DropDownListChosen ID="DropDownListChosen1" runat="server" 
            NoResultsText="No results match." width="350px"            
            DataPlaceHolder="Type Here..." AllowSingleDeselect="true">                
        </asp:DropDownListChosen>
  1. 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.

Also added a repository on github.

https://github.com/arbh89/DropDownListChosen

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
  • 25 Octiber, 2015: Added as a Nuget Package

License

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


Written By
Software Developer Communications
Nicaragua Nicaragua
I am a ASP.Net Software Developer from Nicaragua.

Comments and Discussions

 
Questionthanks but after using this my other java script is not working.. pls help its urgent Pin
PriyankaSharma0168-Jul-14 20:52
PriyankaSharma0168-Jul-14 20:52 
AnswerRe: thanks but after using this my other java script is not working.. pls help its urgent Pin
Angel Blandón9-Jul-14 4:08
Angel Blandón9-Jul-14 4:08 
QuestionThank You :) Pin
Hannihsa8-Jul-14 19:51
Hannihsa8-Jul-14 19:51 
QuestionHow to bind this drop down from sql database Pin
Harishankar Maurya12-May-14 0:44
Harishankar Maurya12-May-14 0:44 
AnswerRe: How to bind this drop down from sql database Pin
Angel Blandón12-May-14 2:30
Angel Blandón12-May-14 2:30 
QuestionSearch option is not working Pin
Nuthan Gowda23-Dec-13 19:02
Nuthan Gowda23-Dec-13 19:02 
AnswerRe: Search option is not working Pin
Moneer Tarabishi21-Oct-14 21:16
Moneer Tarabishi21-Oct-14 21:16 
GeneralRe: Search option is not working Pin
Angel Blandón22-Oct-14 4:21
Angel Blandón22-Oct-14 4:21 
The control has a property call DisableSearchThreshold, this property is set by default to 10 this means that if your dropdown has less items than 10 the search option is disabled, you can change that property value to whatever you want.
GeneralRe: Search option is not working Pin
Moneer Tarabishi24-Oct-14 2:28
Moneer Tarabishi24-Oct-14 2:28 
QuestionMultiple controls on same page - making them unique? Pin
Eldorado22-Dec-13 8:39
Eldorado22-Dec-13 8:39 
AnswerRe: Multiple controls on same page - making them unique? Pin
Angel Blandón2-Dec-13 9:40
Angel Blandón2-Dec-13 9:40 
QuestionCan we turn it to Multi Select ?? Pin
benaref28-Nov-13 23:57
benaref28-Nov-13 23:57 
AnswerRe: Can we turn it to Multi Select ?? Pin
Member 1047980020-Dec-13 13:16
Member 1047980020-Dec-13 13:16 
GeneralRe: Can we turn it to Multi Select ?? Pin
#teve27-Feb-14 9:41
#teve27-Feb-14 9:41 
QuestionTHX Pin
benaref18-Nov-13 21:34
benaref18-Nov-13 21:34 
QuestionIssue in IE9 Pin
Eldorado221-Oct-13 7:33
Eldorado221-Oct-13 7:33 
QuestionHow to override css? Pin
Eldorado28-Oct-13 9:39
Eldorado28-Oct-13 9:39 
AnswerRe: How to override css? Pin
Angel Blandón8-Oct-13 10:19
Angel Blandón8-Oct-13 10:19 
GeneralRe: How to override css? Pin
Eldorado29-Oct-13 3:15
Eldorado29-Oct-13 3:15 
QuestionNice but same problem as ajax combobox Pin
ktkiebel17-Sep-13 16:28
ktkiebel17-Sep-13 16:28 
QuestionSearch option not displaying Pin
anuexuberant11-Sep-13 2:31
anuexuberant11-Sep-13 2:31 
AnswerRe: Search option not displaying Pin
Angel Blandón11-Sep-13 5:42
Angel Blandón11-Sep-13 5:42 
QuestionSelected item not working Pin
Member 102092289-Sep-13 5:56
professionalMember 102092289-Sep-13 5:56 
AnswerRe: Selected item not working Pin
Angel Blandón9-Sep-13 7:27
Angel Blandón9-Sep-13 7:27 
QuestionZIP file broken? Pin
Member 1020758214-Aug-13 13:13
Member 1020758214-Aug-13 13:13 

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

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