Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Working with ASP.NET
MVC and AJAX
Brij Bhushan Mishra
Who am I?
Brij Bhushan Mishra
Microsoft MVP ASP.NET/IIS (2011, 2012, 2013)
Mind Cracker MVP
Former Code Project MVP
Blogge...
Agenda
 Introduction
 Raw Ajax with MVC
 Multiple AJAX Options
 Rendering Partial Page with AJAX
 Using AJAX Helpers
...
Why Ajax
 Rich interface
 No Postback or full page refresh
 Better experience
 Can be animated
 Less bandwidth
 Less...
Raw AJAX
- An event occurs
- Create
XMLHTTPRequest
object
- Send
HTTPrequest
- Process
HTTPRequest
- Create response
and s...
Raw AJAX contd..
Property Description
onreadystate
change
Stores a function (or the name of a function) to be called
autom...
Ajax Options
 Microsoft AJAX
 Component structure
 OOPs concept
 Executes over CLR
 Easy support for WCF and JSON
Ajax Options contd..
 jQuery Ajax
 Available as Plug in
 Many other jQuery plugin can be used
 Easy CSS selectors
 Ea...
Ajax Helpers
 Can create links which sends the ajax request when clicked or even
Ajax Options
 Many events included like
 OnBegin
 OnComplete
 OnFailure
 OnSuccess
 Confirmation Prompt
 Processing...
Ajax and Partial View
 Partial views can be loaded by using AJAX helpers
Ajax and Partial View contd..
 Use jQuery Ajax to load Partial Views
Error Handling with Ajax
 Proper error handling is required to show a proper message
 Error handling with AJAX helper
 ...
JSON and ASP.NET MVC
 To return result in JSON format return JsonResult from controller action
 Both jQuery and Micorsof...
MVC-AJAX-WCF
 Integrating WCF, AJAX and ASP.NET MVC
Demo
Conclusion
Thank You
Upcoming SlideShare
Loading in …5
×

ASP.NET MVC and ajax

3,451 views

Published on

ASP.NET MVC and AJAX presented at C# Corner Delhi chapter event on 20th July

Published in: Technology
  • Be the first to comment

ASP.NET MVC and ajax

  1. 1. Working with ASP.NET MVC and AJAX Brij Bhushan Mishra
  2. 2. Who am I? Brij Bhushan Mishra Microsoft MVP ASP.NET/IIS (2011, 2012, 2013) Mind Cracker MVP Former Code Project MVP Blogger/Author/Speaker http://brijbhushan.net @brij_bhushan brij.mishra@outlook.com
  3. 3. Agenda  Introduction  Raw Ajax with MVC  Multiple AJAX Options  Rendering Partial Page with AJAX  Using AJAX Helpers  Using jQuery AJAX  Error handling with AJAX  JSON and MVC  WCF, MVC and AJAX  Conclusion
  4. 4. Why Ajax  Rich interface  No Postback or full page refresh  Better experience  Can be animated  Less bandwidth  Less response time  Harder to debug
  5. 5. Raw AJAX - An event occurs - Create XMLHTTPRequest object - Send HTTPrequest - Process HTTPRequest - Create response and send back to client - Process the result content - Update the UI
  6. 6. Raw AJAX contd.. Property Description onreadystate change Stores a function (or the name of a function) to be called automatically each time the readyState property changes readyState Holds the status of the XMLHttpRequest. Changes from 0 to 4: 0: request not initialized 1: server connection established 2: request received 3: processing request 4: request finished and response is ready status 200: "OK" 404: Page not found
  7. 7. Ajax Options  Microsoft AJAX  Component structure  OOPs concept  Executes over CLR  Easy support for WCF and JSON
  8. 8. Ajax Options contd..  jQuery Ajax  Available as Plug in  Many other jQuery plugin can be used  Easy CSS selectors  Easy DOM manipulation
  9. 9. Ajax Helpers  Can create links which sends the ajax request when clicked or even
  10. 10. Ajax Options  Many events included like  OnBegin  OnComplete  OnFailure  OnSuccess  Confirmation Prompt  Processing image
  11. 11. Ajax and Partial View  Partial views can be loaded by using AJAX helpers
  12. 12. Ajax and Partial View contd..  Use jQuery Ajax to load Partial Views
  13. 13. Error Handling with Ajax  Proper error handling is required to show a proper message  Error handling with AJAX helper  Error Handling with jQuery AJAX
  14. 14. JSON and ASP.NET MVC  To return result in JSON format return JsonResult from controller action  Both jQuery and Micorsoft works with JSON
  15. 15. MVC-AJAX-WCF  Integrating WCF, AJAX and ASP.NET MVC Demo
  16. 16. Conclusion Thank You

×