asp.net mvc 3 in area of javascript and ajax improvement

26
ASP.NET MVC 3 in JavaScript, Ajax, and Model Validation Ajarn Suthep Sangvirotjanaphat http://facebook.com/suthep Thai Microsoft MVP Since 2004 http://greatfriends.biz

Upload: suthep-sangvirotjanaphat

Post on 17-May-2015

4.033 views

Category:

Technology


3 download

DESCRIPTION

Let's see improvement in ASP.NET MVC 3 about Javascript and Ajax that covers unobtrusive javascript, JSON binding, and especially we will talk deeper about data validation that everyone must be involved. In ASP.NET MVC 3 we can make validation more simpler and better by Model Validation and Remote Validation.Speaker: Ajarn Suthep SangvirotjanaphatA Microsoft Most Valuable Professional (MVP) award since 2004-present. Founder of the GreatFriends.Biz community which is a small but nice and peaceful .net developer community in Thailand. The GreatFriends.Biz also provides training classes in .NET technologies and OOAD/OOP/UML to more than 1,800 developers in several companies and organizations.

TRANSCRIPT

Page 1: ASP.NET MVC 3 in area of Javascript and Ajax improvement

ASP.NET MVC 3in JavaScript, Ajax, and Model ValidationAjarn Suthep Sangvirotjanaphat

http://facebook.com/suthep

Thai Microsoft MVPSince 2004

http://greatfriends.biz

Page 2: ASP.NET MVC 3 in area of Javascript and Ajax improvement

http://GreatFriends.Biz

Agenda

2

Page 3: ASP.NET MVC 3 in area of Javascript and Ajax improvement

o MVC 3o Razoro jQueryo Unobtrusive

JavaScript

o Remote Validationo JSON Bindingo Validation Interfaces

Agenda

Ajarn Suthep Sangvirotjanaphat

http://facebook.com/suthephttp://greatfriends.biz

Page 4: ASP.NET MVC 3 in area of Javascript and Ajax improvement

http://GreatFriends.Biz

ASP.NET MVC 33rd Generation

4

Page 5: ASP.NET MVC 3 in area of Javascript and Ajax improvement

5http://GreatFriends.Biz

ASP.NET MVC 3

We will discover these topics in this session.

Page 6: ASP.NET MVC 3 in area of Javascript and Ajax improvement

http://GreatFriends.Biz

RazorNew View engine

6

Page 7: ASP.NET MVC 3 in area of Javascript and Ajax improvement

7http://GreatFriends.Biz

A little bit about Razor

Page 8: ASP.NET MVC 3 in area of Javascript and Ajax improvement

http://GreatFriends.Biz

jQueryUnobtrusive JavaScript and Client-Side Validation

8

Page 9: ASP.NET MVC 3 in area of Javascript and Ajax improvement

9http://GreatFriends.Biz

jQuery included in Web Form and MVC by default

We have the jQuery.js file ready to use when create a new ASP.NET project

You’ll got jquery 1.4.1 in Web Form and MVC 2

In MVC 3, You’ll got jquery 1.4.4 by default.

Current jQuery version is 1.5.2 (release on Mar 31, 2011)

Do you knowwhich one to use?

Page 10: ASP.NET MVC 3 in area of Javascript and Ajax improvement

10

http://GreatFriends.Biz

Adding jQuery in the page

Page 11: ASP.NET MVC 3 in area of Javascript and Ajax improvement

http://GreatFriends.Biz

Unobtrusive JavaScriptBest practice in JavaScript programming

11

Page 12: ASP.NET MVC 3 in area of Javascript and Ajax improvement

12

http://GreatFriends.Biz

Unobstrusive JavaScript

Page 13: ASP.NET MVC 3 in area of Javascript and Ajax improvement

13

http://GreatFriends.Biz

Unobtrusive JavaScript

It’s a best practice in JavaScript programming.

Separation of functionality.

separate behavior from markup

Page 14: ASP.NET MVC 3 in area of Javascript and Ajax improvement

14

http://GreatFriends.Biz

Unobtrusive JavaScript

Separation of functionality.

independence from specific framework

Page 15: ASP.NET MVC 3 in area of Javascript and Ajax improvement

15

http://GreatFriends.Biz

Client-Side Validation is Enabled by Default in MVC 3

But if want to change from this…

Page 16: ASP.NET MVC 3 in area of Javascript and Ajax improvement

http://GreatFriends.Biz

Remote ValidationWhile still face to user,

turn back to talk with the server mentally.

16

Page 17: ASP.NET MVC 3 in area of Javascript and Ajax improvement

17

http://GreatFriends.Biz

Remote Validation (In Model)

MVC 3 uses Remote validation feature of jQuery Validate plugin.

Action name Controller name

Page 18: ASP.NET MVC 3 in area of Javascript and Ajax improvement

18

http://GreatFriends.Biz

Remote Validation in Action

11:01 AM

11:01 AM

11:02 AM

11:03 AM

Page 19: ASP.NET MVC 3 in area of Javascript and Ajax improvement

19

http://GreatFriends.Biz

Remote Validator (In Controller)

11:01 AM

Page 20: ASP.NET MVC 3 in area of Javascript and Ajax improvement

http://GreatFriends.Biz

JSON BindingSending data from client

to controller is now more easier

20

Page 21: ASP.NET MVC 3 in area of Javascript and Ajax improvement

21

http://GreatFriends.Biz

JSON Binding

11:15 AM

Page 22: ASP.NET MVC 3 in area of Javascript and Ajax improvement

22

http://GreatFriends.Biz

JSON Binding

Page 23: ASP.NET MVC 3 in area of Javascript and Ajax improvement

23

http://GreatFriends.Biz

JSON Binding

Page 24: ASP.NET MVC 3 in area of Javascript and Ajax improvement

http://GreatFriends.Biz

Validation Interfaces

24

Page 25: ASP.NET MVC 3 in area of Javascript and Ajax improvement

25

http://GreatFriends.Biz

Validation Interfaces

Page 26: ASP.NET MVC 3 in area of Javascript and Ajax improvement

26

http://GreatFriends.Biz

GreatFriends.Biz Training

Public or In-house training class for:

OOAD, OOP, ASP.NET MVC, jQuery, VB, C#, Silverlight

00:01 AM

00:02 AM

00:03 AM