2
Answers

What is best way to update a List in MVC

Mohit Vijay

Mohit Vijay

11y
922
1
Hello All,

I am developing a web application using MVC 4.0 and C#. I am stuck with a problem, so looking for community help.

Problem Description:
I have a Model Attribute

Example of Property in Attribute
Name, DislayName, Value, IsOptional, HtmlFieldType

You can say these are Attributes of Person Assets, so Model called PersonAsset will have

List<Attribute>, PersonName, PersonId

So I will have list of attributes fields

@foreach(Attribute attr in Model.ListOfAttributes)
{
@Html.TextBoxFor(attr=>attr.value)
@Html.CheckBoxFor(attr=>attr.IsOptional)
}

When I edit textbox value or checkbox value what Is the option I will to update my Model using entered value. Postback is one of the option, but when we have large model, I dont think it will be good option to postback whole module.
using Javascript, we will totally loose unit testable code, but can adopt this, if we have minimum java script involvement.

Please suggest.

Thanks



Answers (2)