Here's what i'm trying to do: 1 textbox with an Add button, and a ListB开发者_开发知识库ox underneath with a Delete button, along with a bunch of other fields. You can probably guess the functionality: type something in the text box and click Add, it will add that string into the listbox below. Select an item in the listbox and hit Delete, the item is removed from the list. I'd eventually like the textbox to be a dropdownlist as well.
Complicating things, i'm dynamically generating asp pages, which means i can't insert c# code into the asp page (not sure the what the proper name is, but <%= %> tags show up as text in the rendered page. I havent tested it yet, but it may mean javascript wont work either).
Ideally I'd like to keep it all native to ASP MVC (but if there's not other way...). I can think of some ways to do this but will leave behind some nasty code. What's the best way to do this?
Here is the approach: When you hit Add button next to textbox, you will have a postback or say you will have to hit Add action in controller. In your Add action you capture the text that was entered in text box and add it to some collection using which you are populating your dropdown list. You will have to maintain this collection in Cache/Session/TempData or somewhere where it can survive between page cycles. HTH
精彩评论