ASP.NET MVC Editing A Collection Best Practices - Your Opinion

前端 未结 5 619
迷失自我
迷失自我 2020-12-29 10:23

Given the following class, what is your opinion on the best way to handle create/edit where Attributes.Count can be any number.

public class Product {
  pub         


        
5条回答
  •  我在风中等你
    2020-12-29 11:00

    Andrew,

    I'm thinking something a little more difficult than tags. In this simple case a name / value pair .. color: Red; size: 10; material: cotton.

    I think anything that could be used on that could extend to more complex. I.e. Adding a category and adding all its items on the same page. It's relatively easy to add another line using some jQuery, but what's the consensus on sending the info to the ActionMethod?

    You can't code:

    public ActionResult Whatever(stirng attr1Name, string attr2Name, string attr3Name ...
    

    Also I don't think accepting this would work either:

    public ActionResult Whatever(ILIst attributes, string productName ...
    

提交回复
热议问题