it:ad:asp.net:mvc:views:forms:binding:home

IT:AD:ASP.NET:MVC:Views:Forms:Binding

Summary

The traditional mechanism of binding in a View is handled by

  • defining a Model for the View, using the @model keyword
  • using either HtmlHelper.EditorFor or HtmlHelper.DisplayFor, depending on whether read only or read/write is desired:

The basics being Example:

@using Examples.Models
@model MyModel

@using Html.BeginForm() {
  <callout icon="true" type="style="border:solid 2px red;"">
    @Html.EditorFor(m => m.AccountViewModels);
  </callout>
  <input type="submit"/>
}

The HtmlHelper (IT:AD:ASP.NET:MVC:Views:HtmlHelpers) will combine the following

  • Model
  • ModelState
  • ModelMetadata

to output Html to the current Response stream.

Out of the box, you use EditorFor and DisplayFor methods to bind to the Model.

But that's just the tip of the iceberg of the control you can have over the output: IT:AD:ASP.NET:MVC:Views:Forms:Editors

  • /home/skysigal/public_html/data/pages/it/ad/asp.net/mvc/views/forms/binding/home.txt
  • Last modified: 2023/11/04 03:01
  • by 127.0.0.1