开发者

I have a need to give the users the ability to update a dropdown and apply that to their submission

开发者 https://www.devze.com 2023-01-02 19:48 出处:网络
I have an application that I am writing in ASP.NET MVC 2 following the Nerd Dinner tutorial. I am very much a beginner and was looking for examples/tutorials I could follow that would enable me to lea

I have an application that I am writing in ASP.NET MVC 2 following the Nerd Dinner tutorial. I am very much a beginner and was looking for examples/tutorials I could follow that would enable me to learn how to code the following scenario:

  • A user has the option to select an option from a dropdown.
  • If the option is not there then they can enter a new option and add it to the database and list in the dropdown.
  • I would like this to be done without the user leaving the page and what they have开发者_开发技巧 entered so far.
  • I am using a simple Entity Framework 4.0 model which I have built a repository on top of so I have methods I can call to save the filled in user information.
  • If the entry already exists in the database then I would like to offer the user the chance to either select that entry or to continue adding the entry they request because it can be a list of names and of course you can have more than one person with the same name.


I have implemeted this and it follows the following workflow:

1) Provide a button next to the select list to add items

2) Populate the drop-downlist when the page loads

3) When the add button is clicked, implement the UI as you like, we use a jquery dialog box.

4) Post the value to a view (via jQuery Ajax) The view should return a JsonResult

5) Check to see if the item exists, get existing id if exists or add and get new id

6) Returns a JsonResult that contains the new list and the id

7) In the reply to the ajax post, repopulate the select list using jquery and select the item.

HTH

0

精彩评论

暂无评论...
验证码 换一张
取 消