What are the differences between strongly-type view and normal view in asp.net MVC?
When I add a View
by right click on my Controller
into my asp.net MVC project, I have checked a checkbox named Create a strong-typed view. What are the things will change when I checked that checkbox?
Thanks.
With strongly typed views, your view file will have the following directive
@model YourModel
at the top of the file
This signifies to the view that @Html
helpers and @Model
helpers will interact with a class of that type.
For example
@Html.DisplayFor(m => m.MyProperty)
Assuming MyProperty
is a property on YourModel
class.
You can create your views manually, and just add the @model
directive at the top of the page yourself.