I am currently working on a C# project using ASP.NET. And I’d like to implement a list of dropboxes. So a User starts with a dropbox and can select a method and next to the dropbox is a + and – button, which enables a user to add more dropboxes. So I am wondering how can I implement that is it possible to build a List of dropboxes in ASP.NET?
Share
You don’t need any server side code for this, client side scripting is ideal solution for your needs.
Having such HTML:
You need the following pure JavaScript to make it work:
The code has comments, but if you need any further explanation please feel free to ask.
Live test case.
Edit: As you need to read the selected values on the server side code, better approach would be to change the name of each cloned drop down:
Now the tricky part is reading those values. Instead of plain
dropboxlistID.Textyou will have to iterate over all posted values looking for what you need: