15
KnockoutJS with ASP.NET MVC JOEL COCHRAN

Knockout js with mvc

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Knockout js with mvc

KnockoutJS with ASP.NET MVCJOEL COCHRAN

Page 2: Knockout js with mvc

About Me

Expression Blend MVP

ASPInsider Manager Consultant, Sogeti

[email protected]

@joelcochran

joelcochran.com

Page 3: Knockout js with mvc

Windows 8 apps with HTML5 and JavaScript

manning.com/shultz/

37% off!

Use promo code: win8app37

Page 4: Knockout js with mvc

http://madexpo.us

Page 5: Knockout js with mvc

KnockoutJS: MVVM for the web

Separation of concerns

Data binding

Uses modern HTML5

Pure JavaScript

Page 6: Knockout js with mvc

Scripts we’ll use

jQuery – jQuery.com

Knockout – knockoutjs.com

Knockout mapping

All available through Nuget

Page 7: Knockout js with mvc

Traditional ASP.NET MVC

Pros Strongly Typed Razor syntax (familiar)

Intellisense

Start with Templates

Cons Embedded JavaScript

Poor Intellisense

No separation

Page 8: Knockout js with mvc

Stop! Demo time

Page 9: Knockout js with mvc

Knockout Mapping

Fast and (almost) painless

Allows for separation

BUT

Ties Knockout ViewModel to ASP.NET ViewModel

Page 10: Knockout js with mvc

Stop! Demo time

Page 11: Knockout js with mvc

AJAX Calls within Controller

Flexible

Responsive

Performant

Can be done right in the Controller

Good and bad: Can clutter up your Controller

Page 12: Knockout js with mvc

Stop! Demo time

Page 13: Knockout js with mvc

AJAX calls outside the Controller

Service calls

True separation

Can be used in many applications/formats

ASP.NET MVC 4 has this built in with WebApi

Fits very well with the KO approach

Page 14: Knockout js with mvc

Stop! Demo time

Page 15: Knockout js with mvc

Thanks

[email protected]

@joelcochran

joelcochran.com