SlideShare a Scribd company logo
MVC & Javascript


  Eyal Vardi
  CEO E4D Solutions LTD
  Microsoft MVP Visual C#
  blog: www.eVardi.com
Agenda
           Ajax.ActionLink

           Ajax.BeginForm

           Ajax Options




© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Ajax.ActionLink
        Client                                                                   Controller
                                                        XmlHttp
                                           1                                     2
                                                                                      Action
                                                             Data
                                           4                                     3

           <div class="code" id="Demo1">
           @Ajax.ActionLink( "Click Me (Replace)",
                              "ServerTime",
                              new AjaxOptions
                              {
                                 UpdateTargetId = "Demo1",
                                 HttpMethod     = "GET",
                                 InsertionMode = InsertionMode.Replace
                              } )
           </div>

© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Ajax.ActionLink
        Client                                                                   Controller
                                                        XmlHttp
                                           1                                     2
                                                                                      Action
                                                             Data
                                           4                                     3



           public class AjaxController : Controller
           {
                public PartialViewResult ServerTime()
                {
                        return PartialView();
                }
           }



© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Unobtrusive Ajax
        <div class="code" id="Demo1">
        @Ajax.ActionLink( "Click Me (Replace)",
                           "ServerTime",
                           new AjaxOptions
                           {
                              UpdateTargetId = "Demo1",
                              HttpMethod     = "GET",
                              InsertionMode = InsertionMode.Replace
                           } )
        </div>

                     <div class="code" id="Demo1">
                            <a href="/Ajax/Ajax/ServerTime"
                               data-ajax        ="true"
                               data-ajax-method ="GET"
                               data-ajax-mode   ="replace"
                               data-ajax-update ="#Demo1" >Click Me (Replace)</a>
                     </div>


                                                                                 jquery.unobtrusive-ajax.js
© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
AjaxOptions to Attributes
      AjaxOptions                                                  HTML attribute
      Confirm                                                      data-ajax-confirm
      HttpMethod                                                   data-ajax-method
      InsertionMode                                                data-ajax-mode
      LoadingElementDuration                                       data-ajax-loading-duration
      LoadingElementId                                             data-ajax-loading
      OnBegin                                                      data-ajax-begin
      OnComplete                                                   data-ajax-complete
      OnFailure                                                    data-ajax-failure
      OnSuccess                                                    data-ajax-success
      UpdateTargetId                                               data-ajax-update
      Url                                                          data-ajax-url


© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Action Link


© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Ajax.BeginForm
      @using ( Ajax.BeginForm( "Search",new AjaxOptions {
                      UpdateTargetId   = "Result",
                      LoadingElementId = "Loading" } ))
      {
             <input type="text" name="query" />
             <input type="submit" value="Search" />

                  <div id="Loading" > Loading...                     </div>
      }
      <ul id="Result" />



                             <form action="/Ajax/Ajax/Search" id="form0" method="post"
                                 data-ajax        ="true"
                                 data-ajax-loading="#Loading"
                                 data-ajax-mode   ="replace"
                                 data-ajax-update ="#Result" >
                                 . . .
                             </form>

© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Begin Form


© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Ajax Options ( Events )
        <div class="code" id="Demo1">
        @Ajax.ActionLink( "Click Me (Replace)",
                           "ServerTime",
           new AjaxOptions
           {
             UpdateTargetId = "Demo1",
             HttpMethod     = "GET",
             InsertionMode = InsertionMode.Replace,
             Confirm          = "R-U-Sure?",
             OnSuccess        = "alert('OnSuccess')",
             OnBegin          = "alert('OnBegin')",
             OnComplete       = "alert('OnComplete')",
             OnFailure        = "alert('OnFailure')"
           } )
        </div>




© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Client Event Orders
           Confirm

           OnBegin

           Async Communication

           OnSuccess | OnFailure

           OnComplete




© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Client Ajax Context
           get_data()

           get_insertionMode()

           get_request()

           get_response()

           get_updateTarget()



© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Ajax Client Events


© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Ajax Helper




© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il

More Related Content

PPTX
MVC and Razor - Doc. v1.2
PDF
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
KEY
Templates
PDF
GDI Seattle - Intro to JavaScript Class 4
PPTX
Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...
PDF
Polymer
PDF
GWT integration with Vaadin
PPTX
Open Source Ajax Solution @OSDC.tw 2009
MVC and Razor - Doc. v1.2
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
Templates
GDI Seattle - Intro to JavaScript Class 4
Design Patterns for JavaScript Web Apps - JavaScript Conference 2012 - OPITZ ...
Polymer
GWT integration with Vaadin
Open Source Ajax Solution @OSDC.tw 2009

What's hot (20)

PPTX
Javatwo2012 java frameworkcomparison
PDF
Vaadin DevDay 2017 - Data Binding in Vaadin 8
PDF
Deep dive into Android Data Binding
PPT
JavaScript Libraries
PPTX
Magento Indexes
PDF
Local storage in Web apps
PDF
Dialogs in Android MVVM (14.11.2019)
KEY
Html5 For Jjugccc2009fall
PDF
MVVM & Data Binding Library
PPTX
Java script Advance
PDF
22 j query1
KEY
Knockout.js presentation
PPTX
Meet Magento Belarus debug Pavel Novitsky (eng)
PDF
Data Binding in Action using MVVM pattern
PDF
Knockoutjs databinding
PPT
javascript examples
PDF
Java Web Development with Stripes
PDF
Тестирование Magento с использованием Selenium
PDF
Stripes Framework
KEY
Building Web Service Clients with ActiveModel
Javatwo2012 java frameworkcomparison
Vaadin DevDay 2017 - Data Binding in Vaadin 8
Deep dive into Android Data Binding
JavaScript Libraries
Magento Indexes
Local storage in Web apps
Dialogs in Android MVVM (14.11.2019)
Html5 For Jjugccc2009fall
MVVM & Data Binding Library
Java script Advance
22 j query1
Knockout.js presentation
Meet Magento Belarus debug Pavel Novitsky (eng)
Data Binding in Action using MVVM pattern
Knockoutjs databinding
javascript examples
Java Web Development with Stripes
Тестирование Magento с использованием Selenium
Stripes Framework
Building Web Service Clients with ActiveModel
Ad

Similar to Mvc & java script (20)

PPTX
Asp.Net Mvc Internals &amp; Extensibility
PPTX
JSON and XML
ODP
Building a Cloud API Server using Play(SCALA) & Riak
PPTX
Ajax for dummies, and not only.
PDF
Asp.net mvc internals & extensibility
PDF
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
PDF
Building Applications Using Ajax
PDF
Yves & Zed @ Developer Conference 2013
DOCX
Implement Search Screen Using Knockoutjs
PPTX
Asp.NET MVC
PDF
KSDG-iSlide App 開發心得分享
PDF
Pracitcal AJAX
PPT
PPT
PDF
Unit 07: Design Patterns and Frameworks (3/3)
PDF
Workshop: Building Vaadin add-ons
PDF
Overview of The Scala Based Lift Web Framework
PDF
Scala based Lift Framework
PDF
Overview Of Lift Framework
PDF
The vJUG talk about jOOQ: Get Back in Control of Your SQL
Asp.Net Mvc Internals &amp; Extensibility
JSON and XML
Building a Cloud API Server using Play(SCALA) & Riak
Ajax for dummies, and not only.
Asp.net mvc internals & extensibility
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
Building Applications Using Ajax
Yves & Zed @ Developer Conference 2013
Implement Search Screen Using Knockoutjs
Asp.NET MVC
KSDG-iSlide App 開發心得分享
Pracitcal AJAX
Unit 07: Design Patterns and Frameworks (3/3)
Workshop: Building Vaadin add-ons
Overview of The Scala Based Lift Web Framework
Scala based Lift Framework
Overview Of Lift Framework
The vJUG talk about jOOQ: Get Back in Control of Your SQL
Ad

More from Eyal Vardi (20)

PPTX
Why magic
PPTX
Smart Contract
PDF
Rachel's grandmother's recipes
PPTX
Performance Optimization In Angular 2
PPTX
Angular 2 Architecture (Bucharest 26/10/2016)
PPTX
Angular 2 NgModule
PPTX
Upgrading from Angular 1.x to Angular 2.x
PPTX
Angular 2 - Ahead of-time Compilation
PPTX
Routing And Navigation
PPTX
Angular 2 Architecture
PPTX
Angular 1.x vs. Angular 2.x
PPTX
Angular 2.0 Views
PPTX
Component lifecycle hooks in Angular 2.0
PPTX
Template syntax in Angular 2.0
PPTX
Http Communication in Angular 2.0
PPTX
Angular 2.0 Dependency injection
PPTX
Angular 2.0 Routing and Navigation
PPTX
Async & Parallel in JavaScript
PPTX
Angular 2.0 Pipes
PPTX
Angular 2.0 forms
Why magic
Smart Contract
Rachel's grandmother's recipes
Performance Optimization In Angular 2
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 NgModule
Upgrading from Angular 1.x to Angular 2.x
Angular 2 - Ahead of-time Compilation
Routing And Navigation
Angular 2 Architecture
Angular 1.x vs. Angular 2.x
Angular 2.0 Views
Component lifecycle hooks in Angular 2.0
Template syntax in Angular 2.0
Http Communication in Angular 2.0
Angular 2.0 Dependency injection
Angular 2.0 Routing and Navigation
Async & Parallel in JavaScript
Angular 2.0 Pipes
Angular 2.0 forms

Recently uploaded (20)

PPTX
master seminar digital applications in india
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Cell Types and Its function , kingdom of life
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
RMMM.pdf make it easy to upload and study
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Computing-Curriculum for Schools in Ghana
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Classroom Observation Tools for Teachers
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
Presentation on HIE in infants and its manifestations
PDF
VCE English Exam - Section C Student Revision Booklet
master seminar digital applications in india
Complications of Minimal Access Surgery at WLH
Cell Types and Its function , kingdom of life
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
human mycosis Human fungal infections are called human mycosis..pptx
RMMM.pdf make it easy to upload and study
Abdominal Access Techniques with Prof. Dr. R K Mishra
Computing-Curriculum for Schools in Ghana
Module 4: Burden of Disease Tutorial Slides S2 2025
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Classroom Observation Tools for Teachers
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
GDM (1) (1).pptx small presentation for students
Microbial diseases, their pathogenesis and prophylaxis
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Chinmaya Tiranga quiz Grand Finale.pdf
Presentation on HIE in infants and its manifestations
VCE English Exam - Section C Student Revision Booklet

Mvc & java script

  • 1. MVC & Javascript Eyal Vardi CEO E4D Solutions LTD Microsoft MVP Visual C# blog: www.eVardi.com
  • 2. Agenda  Ajax.ActionLink  Ajax.BeginForm  Ajax Options © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: [email protected]
  • 3. Ajax.ActionLink Client Controller XmlHttp 1 2 Action Data 4 3 <div class="code" id="Demo1"> @Ajax.ActionLink( "Click Me (Replace)", "ServerTime", new AjaxOptions { UpdateTargetId = "Demo1", HttpMethod = "GET", InsertionMode = InsertionMode.Replace } ) </div> © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: [email protected]
  • 4. Ajax.ActionLink Client Controller XmlHttp 1 2 Action Data 4 3 public class AjaxController : Controller { public PartialViewResult ServerTime() { return PartialView(); } } © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: [email protected]
  • 5. Unobtrusive Ajax <div class="code" id="Demo1"> @Ajax.ActionLink( "Click Me (Replace)", "ServerTime", new AjaxOptions { UpdateTargetId = "Demo1", HttpMethod = "GET", InsertionMode = InsertionMode.Replace } ) </div> <div class="code" id="Demo1"> <a href="/Ajax/Ajax/ServerTime" data-ajax ="true" data-ajax-method ="GET" data-ajax-mode ="replace" data-ajax-update ="#Demo1" >Click Me (Replace)</a> </div> jquery.unobtrusive-ajax.js © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: [email protected]
  • 6. AjaxOptions to Attributes AjaxOptions HTML attribute Confirm data-ajax-confirm HttpMethod data-ajax-method InsertionMode data-ajax-mode LoadingElementDuration data-ajax-loading-duration LoadingElementId data-ajax-loading OnBegin data-ajax-begin OnComplete data-ajax-complete OnFailure data-ajax-failure OnSuccess data-ajax-success UpdateTargetId data-ajax-update Url data-ajax-url © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: [email protected]
  • 7. Action Link © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: [email protected]
  • 8. Ajax.BeginForm @using ( Ajax.BeginForm( "Search",new AjaxOptions { UpdateTargetId = "Result", LoadingElementId = "Loading" } )) { <input type="text" name="query" /> <input type="submit" value="Search" /> <div id="Loading" > Loading... </div> } <ul id="Result" /> <form action="/Ajax/Ajax/Search" id="form0" method="post" data-ajax ="true" data-ajax-loading="#Loading" data-ajax-mode ="replace" data-ajax-update ="#Result" > . . . </form> © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: [email protected]
  • 9. Begin Form © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: [email protected]
  • 10. Ajax Options ( Events ) <div class="code" id="Demo1"> @Ajax.ActionLink( "Click Me (Replace)", "ServerTime", new AjaxOptions { UpdateTargetId = "Demo1", HttpMethod = "GET", InsertionMode = InsertionMode.Replace, Confirm = "R-U-Sure?", OnSuccess = "alert('OnSuccess')", OnBegin = "alert('OnBegin')", OnComplete = "alert('OnComplete')", OnFailure = "alert('OnFailure')" } ) </div> © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: [email protected]
  • 11. Client Event Orders  Confirm  OnBegin  Async Communication  OnSuccess | OnFailure  OnComplete © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: [email protected]
  • 12. Client Ajax Context  get_data()  get_insertionMode()  get_request()  get_response()  get_updateTarget() © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: [email protected]
  • 13. Ajax Client Events © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: [email protected]
  • 14. Ajax Helper © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: [email protected]