SlideShare a Scribd company logo
A Rich Web Experience
With jQuery, Ajax and .NET


James Johnson
Founder and President, Inland Empire .NET User’s Group

San Francisco .NET Developers User Group
March 28th, 2012
A Rich Web Experience with jQuery, Ajax and .NET
WHO I AM

Founder and President, Inland Empire .NET
 User’s Group
Three-time and current Microsoft MVP – CAD
Software developer by day
Serial netrepreneur by night
AGENDA

jQuery
Ajax
User Experience
JAVASCRIPT

 Used to provide interactivity with a web page
 Enable programmatic access to a web page
 Dynamic
 Weakly typed
 Prototype-based
 Supports closures and higher order function
JAVASCRIPT

 Not to be confused with Java, it has a similar syntax
    {} and ;
 First released as LiveScript in September 1995
 Renamed to JavaScript in December 1995
 Easy to write functions, then copy and paste all over
 Quickly one of the most popular languages for web
  development
    But thought of as a kiddy language
 Advent of Ajax brought JavaScript attention by
  “professionals”
JAVASCRIPT

 Pros
   Dynamic
   Easy to develop with
   Easy to debug
   Similar syntax to “real” languages
 Cons
   Dynamic
   Easy to develop with
   Every browser seems to have it’s own JavaScript
    engine
   Difficult to have same behaviours across browsers
JAVASCRIPT LIBRARIES

 Pre-written JavaScript controls
 Easier development
 Many, many libraries
    Dojo, Echo, Ext, Google Web Toolkit, jQuery, MochiKit,
     MooTools, Prototype, qooxdoo, Rico, script.aculo.us,
     Spry, Yahoo! UI Library
JQUERY

 Released in January 2006 by John Resig
 Free, open source, dual-licensed under MIT and GNU
 Syntax is easier to navigate the DOM
 Handles events, creates animations, modify attributes
 Ajax grooviness baked in
 Used by over 39% of the top 10,000 websites
 Microsoft bundles with ASP.NET Ajax and ASP.NET
  MVC
    Full support from Microsoft
JQUERY BENEFITS

 Fast development
 Solid, standardized library
 Gracefully fails – no glaring errors or frozen pages
 Lots and lots and lots of examples
 Very easy to grok
 All the cool kids use it
 Intellisense with –vsdoc.js
JQUERY SYNTAX

 $(“some element”) or jQuery(“some element”)
 Can select by ID or className
    $(“#myElement”) gets the only ID=“myElement”
    $(“div.myElement”) gets all divs with
     class=“myElement”
 Easy to traverse
    $(“div.main ul li”) – all <li> within div class=“main”
    $(“div.main”).find(“li”) – same as above
    $(“div.main”).find(“li:odd”) – same as above but only
     ODD elements – zero-based
JQUERY SELECTORS

 Matching a set of document elements
 :checkbox, :eq(n), :even, :has(), :first, :last, :focus,
  :not()

$(“input:not(:checked)”);
$(“.myClass:even”);
$(“input:checkbox”);
$(“.my-class:has(p)”);
$(“input[type=„text‟]”);
JQUERY CHAINING

 Once an element is found, reference is kept
 Instead of
   $(“div.myElement”).hide();
   $(“div.myElement”).html(“hi”);
   $(“div.myElement”).addClass(“red”);
   $(“div.myElement”).fadeIn(“slow”);

 Chain the actions
  $(“div.myElement”).hide().html(“hi”)
   .addClass(“red”).fadeIn(“slow”);
JQUERY TRAVERSING

 .children() – all child elements, optional filter
 .each() – iterate through a collection of matched
  elements
 .find() – get descendants of element
 .closest() – first matched element
 .has() – has a filter
 .is() – checks against a selector
 .parent(), .parents()
 .siblings()
 .next()
 .prev()
JQUERY MANIPULATION

 .addClass() – adds a class to an element
 .removeClass() – remove a class from an element
 .append() – inserts content
 .appendTo() – appends element to selector
 .remove() – removes selected element from DOM
 .val(“some text”) – sets value of element
 .html(“some text”) – sets HTML of element
 .prop() – gets a property of element
 .attr() – gets an attribute of element
 .data() – gets a data attribute of an element
JQUERY EVENTS

 Bind to DOM events
   click, hover, focus, keydown, select, submit
 Three main methods to attach event
  $(document).ready(function(){
     $(“myElement”).click(function() {
           doSomething(); });
   });
     Fired when the DOM is completely loaded
  $(“myElement”).live(“click”, function() {
   doSomething(); });
     Fired when the element is created in the DOM
  $(“myElement”).on(“click”, function(){
   doSomething();});
     As of jQuery 1.7, the most efficient way of binding
JQUERY EFFECTS

 Used for animating elements on a page
 fadeIn(), fadeOut(), fadeToggle()
 slideUp(), slideDown(), slideToggle()
 show(), hide(), toggle()
 animate() – create custom animations, pass in a
  map of CSS properties; opacity, position, color
JQUERY AJAX

 Used for loading data into the DOM from a server
  request
 Used for sending data to the server
 .ajax() – main method for Ajax methods
 .get() – get data from the server
 .post() – send data to the server
 .serialize() – prepare form data to send
JQUERY AJAX - SETTINGS

 async – defaulted to true
 beforeSend – used to modify the XMLHTTPRequest
  object
 cache – default to true
 contentType – default to application/x-www-form-
  urlencoded
 data – data to be sent to the server
 dataType – xml, json, script, html
 type – GET, POST
 url – where the request is sent
JQUERY AJAX

 .ajaxSend() – attach function to be run before
  request is sent
 .ajaxStart() – handler called when first Ajax request
  begins
 .ajaxStop() – handler called when all Ajax requests
  are completed
 .ajaxSuccess – function to be called on a successful
  request
JQUERY AJAX

$.ajax({
 url: “/UserGroup/GetGroups”,
 type: “GET”,
 dataType: “json”,
 success: function(data){
    // do something with the result
 }
});
DEMOS
JQUERY UI

 Built with jQuery
 Supports IE 6.0+, Chrome, Firefox 3+, Safari
  3.1+, Opera 9.6+
 Five interactions, eight widgets, various effects and
  utilities
 Themeable
JQUERY UI - INTERACTIONS

 Draggable – Allows DOM element to be dragged
 Droppable – Specifies a DOM element to be target
 Resizeable – Any DOM element to be resizeable
 Selectable – Any DOM element(s) to be selected
 Sortable – Rearrange a list of DOM elements
JQUERY UI - WIDGETS

 Accordion
 Autocomplete
 Button
 Datepicker
 Dialog
 Progressbar
 Slider
 Tabs
JQUERY UI - AUTOCOMPLETE

$(“#element”).autocomplete({
 source: someSource,
 delay: 500,
 minLength: 5
});

 source – the data to use, required. String, array, or callback
 delay – milliseconds before triggering
 minLength – minimum number of characters before triggering
JQUERY UI - DATEPICKER

$(“#element”).datepicker({
 buttonImage: “/images/datepicker.gif”,
 maxDate: “+1m + 1w”,
 constrainInput: true,
 onSelect: function(dateText, inst){
     doSomething();
 }
});

   buttonImage– graphic to use as icon
   maxDate – maximum date allowed
   constrainInput – only characters allowed by dateFormat
   onSelect – function to fire when date is selected
JQUERY UI - DIALOG

$(“#element”).dialog({
 autoOpen: false,
 buttons: { "Ok": function() {
     $(this).dialog("close"); }},
 modal: true,
 minHeight: 300
});

   autoOpen– if true, shows dialog on creation
   buttons– an array of buttons and functions
   modal– other items on page will be disabled
   minHeight– minimum height of dialog
JQUERY UI - THEMES

 24 pre-built themes
 Can create new, or edit existing
JQUERY UI - THEMES

 Modify CSS for new theme
 Download and give name
JQUERY UI - THEMES

   Add to project
<link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/themes/usergroups/jquery-ui-
1.8.17.custom.css")" />
USER EXPERIENCE

 User Registration
   Be as minimal as possible
   Don’t ask for all possible data at start
   Go easy, can always come back for more
USER EXPERIENCE

 Use Ajax/JavaScript to help the user
 Check for existing username before submitting




 Check for existing email and format
USER EXPERIENCE – VALIDATE
                 USERNAME
function validateUserName(elem) {
    var $elem = $(elem);
    var userName = $elem.val();
    var url = "/Account/IsExistingUser/";
    $.get(url, { name: userName }, function (json) {
        if (json) {
            $("#userNameTaken").fadeIn();
            $elem.removeClass("valid")
                  .addClass("invalid");
        } else {
            $("#userNameTaken").fadeOut();
            $elem.removeClass("invalid")
                  .addClass("valid");
        }
    });
}
USER EXPERIENCE – VALIDATE
                 USERNAME

[HttpGet]
public JsonResult IsExistingUser(string name)
{
   return Json(_memberHelper.IsExistingUser (name),
      JsonRequestBehavior.AllowGet );
}
QUESTIONS?

 Slides are at http://slidesha.re/RichWeb
THANK YOU

 James Johnson
 james@latringo.com
 @latringo
 www.latringo.me
 Inland Empire .NET User’s Group
    www.iedotnetug.org
    2 nd Tuesday of each month
    San Bernardino, CA

More Related Content

PPTX
A Rich Web experience with jQuery, Ajax and .NET
James Johnson
 
PDF
jQuery: Nuts, Bolts and Bling
Doug Neiner
 
KEY
jQuery('#knowledge').appendTo('#you');
mikehostetler
 
PPTX
jQuery Fundamentals
Gil Fink
 
PPTX
A to Z about JQuery - Become Newbie to Expert Java Developer
Manoj Bhuva
 
PPTX
SharePoint and jQuery Essentials
Mark Rackley
 
PDF
Write Less Do More
Remy Sharp
 
A Rich Web experience with jQuery, Ajax and .NET
James Johnson
 
jQuery: Nuts, Bolts and Bling
Doug Neiner
 
jQuery('#knowledge').appendTo('#you');
mikehostetler
 
jQuery Fundamentals
Gil Fink
 
A to Z about JQuery - Become Newbie to Expert Java Developer
Manoj Bhuva
 
SharePoint and jQuery Essentials
Mark Rackley
 
Write Less Do More
Remy Sharp
 

What's hot (20)

PPTX
Unobtrusive javascript with jQuery
Angel Ruiz
 
PPT
J query b_dotnet_ug_meet_12_may_2012
ghnash
 
PDF
Organizing Code with JavascriptMVC
Thomas Reynolds
 
PDF
jQuery Introduction
Arwid Bancewicz
 
PPTX
jQuery
Jay Poojara
 
PPTX
jQuery
Dileep Mishra
 
PPTX
Web Development Introduction to jQuery
Laurence Svekis ✔
 
PPTX
JQuery
DevTalk
 
PDF
jQuery Features to Avoid
dmethvin
 
KEY
Nothing Hard Baked: Designing the Inclusive Web
colinbdclark
 
PPTX
JavaScript!
RTigger
 
KEY
The jQuery Library
LearnNowOnline
 
KEY
User Interface Development with jQuery
colinbdclark
 
PPTX
jQuery
Vishwa Mohan
 
PDF
Introduction to jQuery
Zeeshan Khan
 
PDF
jQuery for beginners
Siva Arunachalam
 
PPT
Intoduction on Playframework
Knoldus Inc.
 
PDF
jQuery Essentials
Bedis ElAchèche
 
KEY
The Inclusive Web: hands-on with HTML5 and jQuery
colinbdclark
 
Unobtrusive javascript with jQuery
Angel Ruiz
 
J query b_dotnet_ug_meet_12_may_2012
ghnash
 
Organizing Code with JavascriptMVC
Thomas Reynolds
 
jQuery Introduction
Arwid Bancewicz
 
jQuery
Jay Poojara
 
Web Development Introduction to jQuery
Laurence Svekis ✔
 
JQuery
DevTalk
 
jQuery Features to Avoid
dmethvin
 
Nothing Hard Baked: Designing the Inclusive Web
colinbdclark
 
JavaScript!
RTigger
 
The jQuery Library
LearnNowOnline
 
User Interface Development with jQuery
colinbdclark
 
jQuery
Vishwa Mohan
 
Introduction to jQuery
Zeeshan Khan
 
jQuery for beginners
Siva Arunachalam
 
Intoduction on Playframework
Knoldus Inc.
 
jQuery Essentials
Bedis ElAchèche
 
The Inclusive Web: hands-on with HTML5 and jQuery
colinbdclark
 
Ad

Similar to A Rich Web Experience with jQuery, Ajax and .NET (20)

PPT
jQuery for beginners
Divakar Gu
 
PPTX
Getting started with jQuery
Gill Cleeren
 
PDF
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
 
KEY
Week 4 - jQuery + Ajax
baygross
 
PDF
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Sean Burgess
 
PPTX
jQuery basics for Beginners
Pooja Saxena
 
PDF
Remy Sharp The DOM scripting toolkit jQuery
deimos
 
PDF
J query fundamentals
Attaporn Ninsuwan
 
PDF
Introduction to jQuery
Nagaraju Sangam
 
PPT
J query presentation
sawarkar17
 
PPT
J query presentation
akanksha17
 
PDF
DOM Scripting Toolkit - jQuery
Remy Sharp
 
PDF
Web2.0 with jQuery in English
Lau Bech Lauritzen
 
PPTX
JQuery
Rahul Jain
 
PDF
Learning jquery-in-30-minutes-1195942580702664-3
luckysb16
 
PPTX
Introduction to jQuery
James Johnson
 
PPTX
Jquery beltranhomewrok
Catherine Beltran
 
PPTX
Jquery beltranhomewrok
Catherine Beltran
 
PPTX
How to increase Performance of Web Application using JQuery
kolkatageeks
 
PDF
06 jQuery #burningkeyboards
Denis Ristic
 
jQuery for beginners
Divakar Gu
 
Getting started with jQuery
Gill Cleeren
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
 
Week 4 - jQuery + Ajax
baygross
 
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Sean Burgess
 
jQuery basics for Beginners
Pooja Saxena
 
Remy Sharp The DOM scripting toolkit jQuery
deimos
 
J query fundamentals
Attaporn Ninsuwan
 
Introduction to jQuery
Nagaraju Sangam
 
J query presentation
sawarkar17
 
J query presentation
akanksha17
 
DOM Scripting Toolkit - jQuery
Remy Sharp
 
Web2.0 with jQuery in English
Lau Bech Lauritzen
 
JQuery
Rahul Jain
 
Learning jquery-in-30-minutes-1195942580702664-3
luckysb16
 
Introduction to jQuery
James Johnson
 
Jquery beltranhomewrok
Catherine Beltran
 
Jquery beltranhomewrok
Catherine Beltran
 
How to increase Performance of Web Application using JQuery
kolkatageeks
 
06 jQuery #burningkeyboards
Denis Ristic
 
Ad

More from James Johnson (6)

PPTX
La sql
James Johnson
 
PPTX
Entity Framework Database and Code First
James Johnson
 
PPTX
Real World MVC
James Johnson
 
PPTX
ASP.NET MVC and Entity Framework 4
James Johnson
 
PPTX
MVC and Entity Framework 4
James Johnson
 
PPTX
MVC and Entity Framework
James Johnson
 
Entity Framework Database and Code First
James Johnson
 
Real World MVC
James Johnson
 
ASP.NET MVC and Entity Framework 4
James Johnson
 
MVC and Entity Framework 4
James Johnson
 
MVC and Entity Framework
James Johnson
 

Recently uploaded (20)

PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
PPT
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
Software Development Methodologies in 2025
KodekX
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Doc9.....................................
SofiaCollazos
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Software Development Methodologies in 2025
KodekX
 

A Rich Web Experience with jQuery, Ajax and .NET

  • 1. A Rich Web Experience With jQuery, Ajax and .NET James Johnson Founder and President, Inland Empire .NET User’s Group San Francisco .NET Developers User Group March 28th, 2012
  • 3. WHO I AM Founder and President, Inland Empire .NET User’s Group Three-time and current Microsoft MVP – CAD Software developer by day Serial netrepreneur by night
  • 5. JAVASCRIPT  Used to provide interactivity with a web page  Enable programmatic access to a web page  Dynamic  Weakly typed  Prototype-based  Supports closures and higher order function
  • 6. JAVASCRIPT  Not to be confused with Java, it has a similar syntax  {} and ;  First released as LiveScript in September 1995  Renamed to JavaScript in December 1995  Easy to write functions, then copy and paste all over  Quickly one of the most popular languages for web development  But thought of as a kiddy language  Advent of Ajax brought JavaScript attention by “professionals”
  • 7. JAVASCRIPT  Pros  Dynamic  Easy to develop with  Easy to debug  Similar syntax to “real” languages  Cons  Dynamic  Easy to develop with  Every browser seems to have it’s own JavaScript engine  Difficult to have same behaviours across browsers
  • 8. JAVASCRIPT LIBRARIES  Pre-written JavaScript controls  Easier development  Many, many libraries  Dojo, Echo, Ext, Google Web Toolkit, jQuery, MochiKit, MooTools, Prototype, qooxdoo, Rico, script.aculo.us, Spry, Yahoo! UI Library
  • 9. JQUERY  Released in January 2006 by John Resig  Free, open source, dual-licensed under MIT and GNU  Syntax is easier to navigate the DOM  Handles events, creates animations, modify attributes  Ajax grooviness baked in  Used by over 39% of the top 10,000 websites  Microsoft bundles with ASP.NET Ajax and ASP.NET MVC  Full support from Microsoft
  • 10. JQUERY BENEFITS  Fast development  Solid, standardized library  Gracefully fails – no glaring errors or frozen pages  Lots and lots and lots of examples  Very easy to grok  All the cool kids use it  Intellisense with –vsdoc.js
  • 11. JQUERY SYNTAX  $(“some element”) or jQuery(“some element”)  Can select by ID or className  $(“#myElement”) gets the only ID=“myElement”  $(“div.myElement”) gets all divs with class=“myElement”  Easy to traverse  $(“div.main ul li”) – all <li> within div class=“main”  $(“div.main”).find(“li”) – same as above  $(“div.main”).find(“li:odd”) – same as above but only ODD elements – zero-based
  • 12. JQUERY SELECTORS  Matching a set of document elements  :checkbox, :eq(n), :even, :has(), :first, :last, :focus, :not() $(“input:not(:checked)”); $(“.myClass:even”); $(“input:checkbox”); $(“.my-class:has(p)”); $(“input[type=„text‟]”);
  • 13. JQUERY CHAINING  Once an element is found, reference is kept  Instead of $(“div.myElement”).hide(); $(“div.myElement”).html(“hi”); $(“div.myElement”).addClass(“red”); $(“div.myElement”).fadeIn(“slow”);  Chain the actions $(“div.myElement”).hide().html(“hi”) .addClass(“red”).fadeIn(“slow”);
  • 14. JQUERY TRAVERSING  .children() – all child elements, optional filter  .each() – iterate through a collection of matched elements  .find() – get descendants of element  .closest() – first matched element  .has() – has a filter  .is() – checks against a selector  .parent(), .parents()  .siblings()  .next()  .prev()
  • 15. JQUERY MANIPULATION  .addClass() – adds a class to an element  .removeClass() – remove a class from an element  .append() – inserts content  .appendTo() – appends element to selector  .remove() – removes selected element from DOM  .val(“some text”) – sets value of element  .html(“some text”) – sets HTML of element  .prop() – gets a property of element  .attr() – gets an attribute of element  .data() – gets a data attribute of an element
  • 16. JQUERY EVENTS  Bind to DOM events  click, hover, focus, keydown, select, submit  Three main methods to attach event $(document).ready(function(){ $(“myElement”).click(function() { doSomething(); }); });  Fired when the DOM is completely loaded $(“myElement”).live(“click”, function() { doSomething(); });  Fired when the element is created in the DOM $(“myElement”).on(“click”, function(){ doSomething();});  As of jQuery 1.7, the most efficient way of binding
  • 17. JQUERY EFFECTS  Used for animating elements on a page  fadeIn(), fadeOut(), fadeToggle()  slideUp(), slideDown(), slideToggle()  show(), hide(), toggle()  animate() – create custom animations, pass in a map of CSS properties; opacity, position, color
  • 18. JQUERY AJAX  Used for loading data into the DOM from a server request  Used for sending data to the server  .ajax() – main method for Ajax methods  .get() – get data from the server  .post() – send data to the server  .serialize() – prepare form data to send
  • 19. JQUERY AJAX - SETTINGS  async – defaulted to true  beforeSend – used to modify the XMLHTTPRequest object  cache – default to true  contentType – default to application/x-www-form- urlencoded  data – data to be sent to the server  dataType – xml, json, script, html  type – GET, POST  url – where the request is sent
  • 20. JQUERY AJAX  .ajaxSend() – attach function to be run before request is sent  .ajaxStart() – handler called when first Ajax request begins  .ajaxStop() – handler called when all Ajax requests are completed  .ajaxSuccess – function to be called on a successful request
  • 21. JQUERY AJAX $.ajax({ url: “/UserGroup/GetGroups”, type: “GET”, dataType: “json”, success: function(data){ // do something with the result } });
  • 22. DEMOS
  • 23. JQUERY UI  Built with jQuery  Supports IE 6.0+, Chrome, Firefox 3+, Safari 3.1+, Opera 9.6+  Five interactions, eight widgets, various effects and utilities  Themeable
  • 24. JQUERY UI - INTERACTIONS  Draggable – Allows DOM element to be dragged  Droppable – Specifies a DOM element to be target  Resizeable – Any DOM element to be resizeable  Selectable – Any DOM element(s) to be selected  Sortable – Rearrange a list of DOM elements
  • 25. JQUERY UI - WIDGETS  Accordion  Autocomplete  Button  Datepicker  Dialog  Progressbar  Slider  Tabs
  • 26. JQUERY UI - AUTOCOMPLETE $(“#element”).autocomplete({ source: someSource, delay: 500, minLength: 5 });  source – the data to use, required. String, array, or callback  delay – milliseconds before triggering  minLength – minimum number of characters before triggering
  • 27. JQUERY UI - DATEPICKER $(“#element”).datepicker({ buttonImage: “/images/datepicker.gif”, maxDate: “+1m + 1w”, constrainInput: true, onSelect: function(dateText, inst){ doSomething(); } });  buttonImage– graphic to use as icon  maxDate – maximum date allowed  constrainInput – only characters allowed by dateFormat  onSelect – function to fire when date is selected
  • 28. JQUERY UI - DIALOG $(“#element”).dialog({ autoOpen: false, buttons: { "Ok": function() { $(this).dialog("close"); }}, modal: true, minHeight: 300 });  autoOpen– if true, shows dialog on creation  buttons– an array of buttons and functions  modal– other items on page will be disabled  minHeight– minimum height of dialog
  • 29. JQUERY UI - THEMES  24 pre-built themes  Can create new, or edit existing
  • 30. JQUERY UI - THEMES  Modify CSS for new theme  Download and give name
  • 31. JQUERY UI - THEMES  Add to project <link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/themes/usergroups/jquery-ui- 1.8.17.custom.css")" />
  • 32. USER EXPERIENCE  User Registration  Be as minimal as possible  Don’t ask for all possible data at start  Go easy, can always come back for more
  • 33. USER EXPERIENCE  Use Ajax/JavaScript to help the user  Check for existing username before submitting  Check for existing email and format
  • 34. USER EXPERIENCE – VALIDATE USERNAME function validateUserName(elem) { var $elem = $(elem); var userName = $elem.val(); var url = "/Account/IsExistingUser/"; $.get(url, { name: userName }, function (json) { if (json) { $("#userNameTaken").fadeIn(); $elem.removeClass("valid") .addClass("invalid"); } else { $("#userNameTaken").fadeOut(); $elem.removeClass("invalid") .addClass("valid"); } }); }
  • 35. USER EXPERIENCE – VALIDATE USERNAME [HttpGet] public JsonResult IsExistingUser(string name) { return Json(_memberHelper.IsExistingUser (name), JsonRequestBehavior.AllowGet ); }
  • 36. QUESTIONS?  Slides are at http://slidesha.re/RichWeb
  • 37. THANK YOU  James Johnson  [email protected]  @latringo  www.latringo.me  Inland Empire .NET User’s Group  www.iedotnetug.org  2 nd Tuesday of each month  San Bernardino, CA