Created
December 11, 2014 11:12
-
-
Save Deathspike/ff90e5058a51e69ea62f to your computer and use it in GitHub Desktop.
ASP.NET MVC Strong-Typed Views with ViewModels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @model MyViewModel | |
| <div>My strong-typed name is @Model.Name</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Web.Mvc; | |
| namespace MyExample | |
| { | |
| public class MyController : Controller | |
| { | |
| [HttpGet] | |
| public ActionResult Index() | |
| { | |
| return View(new MyViewModel | |
| { | |
| Name = "Roel van Uden" | |
| }); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace MyExample | |
| { | |
| public class MyViewModel | |
| { | |
| public string Name { get; set; } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment