BUILD YOUR WEB APPLICATION WITH ASP.NET MVC 2 FROM SCRATCH<br />ZZ Black Coffee #5 : Web Programming<br />ChalermponAreepo...
Agenda<br />Demo Fast build web mvc application <br />Routing<br />Control<br />Model<br />View<br />Unit Testing<br />Ext...
Demo Fast build web mvc application<br />
Routing<br />Responsibility<br />Map request to controller action<br />Create out going Url corresponds with controller ac...
Controller<br />Action Method<br />{action}  =  controller method<br />Parameter<br />{controller}/{action}/{id}  {id} = p...
Controller (2)<br />ActionResult is abstract class for return action result type<br />ViewResult, RedirectResult, JsonResu...
VIew<br />Strong Typed Views<br />public partial class Index : ViewPage<Product> {…}<br />Controller  : return View(produc...
Model<br />ViewModel<br />Input<br />Report<br />DomainModel<br />Business Object<br />Business Rule<br />Business Method<...
Extend mvc<br />AJAX<br />Required MicrosoftAjax.js, MicrosoftMvcAjax.js<br />Sample code  view<br /><%: Using(Ajax.BeginF...
Upcoming SlideShare
Loading in...5
×

Build your web app with asp.net mvc 2 from scratch

3,410

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
3,410
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
45
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Build your web app with asp.net mvc 2 from scratch

  1. 1. BUILD YOUR WEB APPLICATION WITH ASP.NET MVC 2 FROM SCRATCH<br />ZZ Black Coffee #5 : Web Programming<br />ChalermponAreepong : Nine (นาย)<br />Greatfriends community lead<br />Microsoft MVP : ASP.NET<br />
  2. 2. Agenda<br />Demo Fast build web mvc application <br />Routing<br />Control<br />Model<br />View<br />Unit Testing<br />Extend MVC 2 DI/ Ajax/ Telirik MVC UI<br />Question / Answer<br />
  3. 3. Demo Fast build web mvc application<br />
  4. 4. Routing<br />Responsibility<br />Map request to controller action<br />Create out going Url corresponds with controller action<br />Route Pattern<br />Default parameter value<br />routes.aMapRoute(“simple”, “{controller}/{action}/{id}”, new {id=“”});<br />Constraints with Regular Expression<br />Cacheable - Data parameter<br />
  5. 5. Controller<br />Action Method<br />{action} = controller method<br />Parameter<br />{controller}/{action}/{id} {id} = parameter for controller method<br />Multi parameter {controller}/{action}/{id},{name}<br />routes.MapRoute(“hello,”say/hello/{id},{name}”, new { Controller = “say”, action = “hello”});<br />Default parameter <br />test([DefaultValue(10)]int max) {…}<br />C#4 test(int max = 10) {…}<br />
  6. 6. Controller (2)<br />ActionResult is abstract class for return action result type<br />ViewResult, RedirectResult, JsonResult, etc.<br />Accept Verb<br />[HttpGet] ActionResult Edit(string id){…}<br />[HttpPost] ActionResult Edit(string id, FormCollection form) {…}<br />Asynchronous Controller<br />
  7. 7. VIew<br />Strong Typed Views<br />public partial class Index : ViewPage<Product> {…}<br />Controller : return View(product);<br />ViewModel custom class to render view by requirement<br />Html Helper class<br />ViewEngine<br />
  8. 8. Model<br />ViewModel<br />Input<br />Report<br />DomainModel<br />Business Object<br />Business Rule<br />Business Method<br />Data Access<br />ORM<br />Repository Pattern<br />
  9. 9. Extend mvc<br />AJAX<br />Required MicrosoftAjax.js, MicrosoftMvcAjax.js<br />Sample code view<br /><%: Using(Ajax.BeginForm(“HelloAjax”, new AjaxOptions { UpdateTargetId = “results”})) { %><br /><%: Html.Textbox(“query”, null, new {size=40}) %> <br /><input type=“submit /><br /><% } %><br /><div id=“results”> </div><br />Sample code controller<br />public ActionResultHelloAjax(string query) <br />{ <br />if(Request.IsAjaxRequest())<br />{ return Content(“You entered” + query);}<br />else { return RedirectToAction(“Index”, new {query = query}); }<br />}<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×