Adding items to DropDownList in JavaScript

E

Emmanuel

hi,

I have an ASP.NET dropdownlist filled with some ListItems. At the client
side the user can add more list items to the same dropdownlist through a
series of javascript functions.

The problem is that the items added at the client side are not available on
the server side when postback occurs. While i understand this could be a
problem caused by the ViewState i don't know how i could obtain the values
added by the user and render them back to the client once postback is done.

Anyone can help please?

regards,
 
M

mnichols

Hi,

I think that with or without ASP.NET you are going to have a challenge
since droplists (<select />) only return the values of their selected
items and not their droplist items.

You will have to use an alternative approach, some possibilities are:
- Use an edit to store new values and trigger a postback each time the
user adds an item. Then you can update the droplist on postback.
- Another more complicated solution would be to create hidden edits on
the fly using javascript and the DOM.
- Possibly you could use a hidden edit and store comma delimited label/
value pairs in it though this can get tricky if the user decides to add
an item with a comma in it.

mn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top