Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Editable dropdown box in ASP.NetMVC

I have asp.net MVC .Net core 6 project. I need editable dropdown box in one of the view. I tried datalist & javascript autocomplete functionality but both of them not working. My code in view is :

  <input type="text" name="medCompany" id="medCompany" list="ddlmedCompany" class="form-control form-control-lg" />
 <datalist id="ddlmedCompany" class="form-control form-control-lg" >
        @foreach (var item in Model.lstmedCompany)
         {
           <option>@item.Text</option>
          }
   </datalist>

But this gives look as below :
enter image description here

and dropdwon box is :
enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What I need is only dropdown box and not test box which is displayed below dropdown box. How can I achieve this.

>Solution :

Try to remove class="form-control form-control-lg" from datalist

  <input type="text" name="medCompany" id="medCompany" list="ddlmedCompany"  class="form-control form-control-lg" />
 <datalist id="ddlmedCompany"  >
        @foreach (var item in Model.lstmedCompany)
         {
           <option>@item.Text</option>
          }
   </datalist>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading