Implementing a ComboBox control in ASP.NET

The DropDownList control does not provide editability, i.e. does not act as a ComboBox. The only thing you can do with DropDownList is to pick up an item from a list, but you cannot type in your own text. Is this correct? If yes, could you please advise how to implement a kind of a ComboBox control in ASP.NET? Thank you.
Platform: Win2000
Implementing the ComboBox in ASP.NET would consist of: a composite custom control, containing a textbox for the editable region, an image for the "faked" dropdown, next to the textbox, and a <div> containing all items. With JavaScript, you'd have to react to the click on the image, and show/hide the div (i.e. set its "display:block" or "display:none"). You'd have to take care of positioning too. Alternatively, you could try having both a textbox and a dropdown list with absolute positioning, overlapping each other. You can make the textbox narrower than the dropdown so the arrow appears (the dropdown should have it's Z-order less than the textbox'). Then, through JavaScript, when the user clicks on an item in the dropdown, you set the textbox value accordingly.
This was first published in June 2004

Dig Deeper on ASP.NET and Ajax development

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.



Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: