Is not the @Model MyModelClass
notation not supported in VB Razor Views? It's not working for me. What is the construct for it?
The @model directive provides a cleaner and more concise way to reference strongly-typed models from view files. This works (and is still supported with ASP.NET MVC 3) – but is a little verbose. The above syntax is conceptually the same as before (except with a lot fewer characters).
The Razor syntax consists of Razor markup, C#, and HTML. Files containing Razor generally have a . cshtml file extension.
The declaration at the top will do two things for you: It will allow intellisence to know what type you are using when you type in @Model or use any of the Html helper extensions. It will also check at runtime that model passed in can be cast to the type the view expects.
Razor allows you to write a mix of HTML and server-side code using C# or Visual Basic. Razor view with visual basic syntax has . vbhtml file extension and C# syntax has . cshtml file extension.
The equivalent construct to @model
statement in C# Razor in VB is @ModelType
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With