2

I want to write a form to submit data about people that could have a greatly varying amount of fields, it is getting this data from an eav database. My idea was to write a model with a Dictionary of parameters. Something like

public class MyModel
{
    public Dictionary<string,string> Parameters {get;set;}
}

Where the key would be the parameter name and the value would be the value. Then in the view I would just create a Html.TextBoxFor(...) each parameter in the dictionary and submit the form. The model would also handle stuff like populating the dictionary etc.

Another intern told me I should just use json and ajax/angularjs. The form isn't smart at all, just a big list of fields you have to fill in then submit.

Is there a downside to doing it just in razor and server code in this case?

Fantastic Mr Fox
  • 32,495
  • 27
  • 95
  • 175
Tenderdude
  • 311
  • 3
  • 9
  • Thank you for editing my post. It is much cleaner. I am new to posting and will try to make my questions cleaner in the future. – Tenderdude Jun 13 '16 at 19:18

1 Answers1

2

If you are just editing preexisting data, you don't have to add any new data, then doing it with pure razor should be just fine, check this question, I think it will help you. However if you have dynamically add or delete, some pairs then this approach will not be enough and you should consider listening to the other intern.

Community
  • 1
  • 1
Luiso
  • 4,173
  • 2
  • 37
  • 60
  • I would get the data about needed fields to create the forms, and then use the form data to create a new database entry. No dynamic changes just an entry after form is finished. So just razor should be fine right? – Tenderdude Jun 13 '16 at 19:05
  • From what you say I think so , yes, that should be enough – Luiso Jun 13 '16 at 19:30