Saturday, 18 June 2011

MVC 2 features.

Strongly types helpers

MVC1 : Html.TextBox("Name");
MVC2 : Html.EditorFor(person => person.Name);

With MVC1 there is no way to check the syntax of the model properties such as Name. One would have to type it twice like so: Html.TextBox("Name", Model.Name); for a strongly typed view.

Data Annotations.

[StringLength (25, ErrorMessage = "Invalid Length")]
public string Name { get; set; }

Annotations such as this, are explicit constraints in the model itself. Validation is simpler because most validations can be such data annotations.

Templated Views. TODO
Areas. TODO
Asynchronous Controllers. TODO
Html.RenderAction() TODO


No comments: