Allow users to type dynamic option (autotag) in jQuery Select2 DropDownList in ASP.Net

Last Reply 9 months ago By dharmendr

Posted 9 months ago


I'm using a textbox that accepts multiple values with search functionality. Now, the problem is that it's not allowing me to enter values which are not already in the dropdownlist.

I tried jquery plugin but it's not working currently. below is my code:


<script type="text/javascript" src=""></script>
<link rel="stylesheet" href="" />
<script type="text/javascript" src=""></script>
<script type="text/javascript">
    $(function () {
            placeholder: "select technologies that you've experience in",
            allowClear: true
        $('[id*=ddl1]').on('change', function () {
        $('[id*=ddl1]').keydown(function (e) {
            if (e.keyCode == 13 || e.keyCode == 32) {
                //alert('You Press enter');
                var getValue = $(this).val();
                $('[id*=ddl1]').append('<span class="email-ids">' + getValue + ' <span class="cancel-email">x</span></span>');

ASPX Markup:

<div class="col-md-6">
    <div class="form-group">
        <asp:DropDownList ID="ddl1" runat="server" multiple="multiple" 
            CssClass="form-control js-example-placeholder-single form-control ddl1"
            ToolTip="Select ">


Posted 9 months ago

Hi jmprateek,

Set the tags attribute true to allow you adding new tag taht are not in the list.

    placeholder: "select technologies that you've experience in",
    allowClear: true,
    tags: true