0

I'm trying to create a ComboBox for a ASP.NET MVC5 application. Is this as simple as:

  1. Create a Select in a razor page
  2. Add an input field as an option
  3. Then add options from the data past to the view

How should the search functionality of the input be written? In JavaScript/JQuery or something else? An example would be great! Is there any build in things to create this, maybe something like comboboxfor from the asp.net mvc side? Does Twitter-Bootstrap have anything built in?

I understand comboboxes as explained here. I don't think it would be hard to implement, I just want to implement it the correct way.

Heres a picture of something that I want the results to look like

enter image description here

3
  • As much as I’d like to answer, I’m not sure I fully understand the question. Comboboxes (in the web world) does not allow user input. You can fool the user into thinking he’s typing inside the comboboxe but that requires some CSS trick. What is this input field option that you speak of? Where is it placed? Commented Mar 12, 2014 at 17:59
  • @Vlince I've added a picture of what I want it too look like, but I want the other options to only show if you click the arrow. Commented Mar 12, 2014 at 19:15
  • Vlince is pretty much correct, but it can be done. Although i have only ever seen it with a third party tool like Kendo UI. Commented Mar 12, 2014 at 20:17

1 Answer 1

2

Bootstrap-Buttons with dropdowns:

<form>
<div class="row">
<div class="col-lg-6">
    <div class="input-group">
        <input type="text" class="form-control" />
        <div class="input-group-btn">
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                <span class="caret"></span>
            </button>
            <ul class="dropdown-menu pull-right">
                <li><a href="#">Action</a></li>
                <li><a href="#">Another action</a></li>
                <li><a href="#">Something else here</a></li>
            </ul>
        </div>
    </div>
</div>
</div>
</form>
Sign up to request clarification or add additional context in comments.

2 Comments

Do you know how to make the dropdown-menu show by default?
If you want to make the dropdown menu open by default use the class="input-group-btn open" instead of class="input-group-btn".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.