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

Post on 17-May-2015

4,030 views 3 download

Tags:

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

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

http://facebook.com/suthep

Thai Microsoft MVPSince 2004

http://greatfriends.biz

http://GreatFriends.Biz

Agenda

2

o MVC 3o Razoro jQueryo Unobtrusive

JavaScript

o Remote Validationo JSON Bindingo Validation Interfaces

Agenda

Ajarn Suthep Sangvirotjanaphat

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

http://GreatFriends.Biz

ASP.NET MVC 33rd Generation

4

5http://GreatFriends.Biz

ASP.NET MVC 3

We will discover these topics in this session.

http://GreatFriends.Biz

RazorNew View engine

6

7http://GreatFriends.Biz

A little bit about Razor

http://GreatFriends.Biz

jQueryUnobtrusive JavaScript and Client-Side Validation

8

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?

10

http://GreatFriends.Biz

Adding jQuery in the page

http://GreatFriends.Biz

Unobtrusive JavaScriptBest practice in JavaScript programming

11

12

http://GreatFriends.Biz

Unobstrusive JavaScript

13

http://GreatFriends.Biz

Unobtrusive JavaScript

It’s a best practice in JavaScript programming.

Separation of functionality.

separate behavior from markup

14

http://GreatFriends.Biz

Unobtrusive JavaScript

Separation of functionality.

independence from specific framework

15

http://GreatFriends.Biz

Client-Side Validation is Enabled by Default in MVC 3

But if want to change from this…

http://GreatFriends.Biz

Remote ValidationWhile still face to user,

turn back to talk with the server mentally.

16

17

http://GreatFriends.Biz

Remote Validation (In Model)

MVC 3 uses Remote validation feature of jQuery Validate plugin.

Action name Controller name

18

http://GreatFriends.Biz

Remote Validation in Action

11:01 AM

11:01 AM

11:02 AM

11:03 AM

19

http://GreatFriends.Biz

Remote Validator (In Controller)

11:01 AM

http://GreatFriends.Biz

JSON BindingSending data from client

to controller is now more easier

20

21

http://GreatFriends.Biz

JSON Binding

11:15 AM

22

http://GreatFriends.Biz

JSON Binding

23

http://GreatFriends.Biz

JSON Binding

http://GreatFriends.Biz

Validation Interfaces

24

25

http://GreatFriends.Biz

Validation Interfaces

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