Problem solve Get help with specific problems with your technologies, process and projects.

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 last 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.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.