name
is what is used to help the model binder figure out how to bind to the data server side. It's especially important when it comes to binding to collections, because you include an index along with that name which allows MVC to distinguish between the different elements in that collection.
As an example, suppose you have the following class:
public class Student
{
public int Id { get; set; }
public string Name { get; set; }
}
Now let's say you want to bind to a collection, like so:
[HttpPost]
public ActionResult UpdateStudents(List<Student> students)
{
// ...
}
In order for this to work, MVC relies upon having the correct name
attribute to allow this to happen. Like so:
<input type="text" name="[0].Id" value="1" />
<input type="text" name="[0].Name" value="Dave" />
<input type="text" name="[1].Id" value="2" />
<input type="text" name="[1].Name" value="Bob" />
The number in each name
attribute is the index. As you can see, this essentially allows the different properties of a model to be associated, based on that index, so now MVC can properly bind the data to List<Student> students
in the action without you having to do anything else to achieve it.
For some other examples of this, including how to let EditorTemplates
generate these names for you, and also how to use non-sequential indices, see Phil Haack's article Model Binding To A List.