1 / 29

Enhancing Web Applications with ASP.NET MVC3 and jQuery

In this presentation by David Fekke from JaxDUG, you'll learn how to effectively use ASP.NET MVC3 alongside jQuery to create engaging web applications. The session covers advanced topics such as AJAX integration, managing scripts and styles efficiently, and implementing client-side validation. Discover how to utilize partial views for dynamic content, work with JSON responses, and take advantage of jQuery UI widgets. Whether you are building web or iOS applications, this talk provides practical insights to improve interactivity and user experience in your projects.

mauve
Télécharger la présentation

Enhancing Web Applications with ASP.NET MVC3 and jQuery

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JaxDUG March 2012 Using ASP.NET MVC3 w/ JQuery

  2. Who am I • David Fekke • Web Applications and iOSApps • http://fekke.com/blog/ • JaxDUG, JSSUG, JaxJUG and JaxFusion • David Fekke L.L.C.

  3. .NET Framework ASP.NET MVC 3

  4. JavaScript Framework Jquery 1.7

  5. Validation

  6. Interactivity

  7. AJAX

  8. Widgets and UI

  9. Semantic Web • Paint HTML • Style and Skin using CSS • Keep CSS at top of page • Keep Scripts at bottom of page • Update using Ajax • Use JsonActionResult

  10. Sections • Create sections in your Layout file • Use section in head for styles • Use section at bottom for scripts • @RenderSection("StyleSection", false) • @section StyleSection in our view

  11. <!DOCTYPE html> <html> <head> <title>@ViewBag.Title</title> @RenderSection(“StyleSection”, false) <head> <body> … Rest of your html body here … @RenderSection(“Scripts”, false) <body> <html>

  12. <appSettings> <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> </appSettings>

  13. public class People { public int ID { get; set; } [Required(ErrorMessage="Firstname is required")] [StringLength(50, ErrorMessage="Field too long")] public string FirstName { get; set; } [Required(ErrorMessage = "Lastname is required")] [StringLength(50, ErrorMessage = " Field too long ")] public string LastName { get; set; } [Required(ErrorMessage = "Email is required")] [StringLength(256, ErrorMessage = " Field too long by 256 chars")] [RegularExpression(".+\\@.+\\..+", ErrorMessage = "email not valid")] public string Email { get; set; } }

  14. <input class="text-box single-line" data-val="true" data-val-length="Field too long" data-val-length-max="50" data-val-required="Firstname…" id="FirstName" name="FirstName" type="text" value="" />

  15. Binding to events • Keep scripts at bottom of page • $(“#myButton”).click(fn(e)); • $(“#myButton”).bind(“click”, fn(e)); • $(“#myButton”).delegate(“td”, “click”, fn(e)); • $(“#myButton”).on(“click”, “td”, fn(e));

  16. Please Avoid <sometagonclick=“fn();” /> $(sometag).live(fn);

  17. Event object functions • event.preventDefault(); • event.stopPropagation(); • event.stopImmediatePropagation();

  18. Partial Views • Use partials for Dialogs and pop-ups • $(“#myDiv”).load(“/controller/action”); • Partials are also good for Tabs

  19. Ajax • $.ajax(); • $.getJSON(); • $.post(); • $.get(); • $.load();

  20. Ajax function $.ajax({url:“/myController/myAction",  type:“POST”, data: someVar,  success:function(result){    $("#results").append(result);}});

  21. getJSON function $.getJSON(“/mycontroller/myAction/232”, function(data) { … }); public ActionResultSampleJsonResponse(int Id) { intmynumber = providerGetNumber(Id); return Json(mynumber, JsonRequestBehavior.AllowGet); }

  22. JQueryUI • Dragging • Widgets, Accordian, Tabs, Datepicker, Dialog, Slider and Autocomplete • Utilities Widget framework • Effects • Grid control coming

  23. 3rd Party Jquery Grids • tableSorter • jqGrid • Flexigrid • DataTables • SlickGrid • Ingrid

  24. demo

  25. How to Contact Me • davidfekke@gmail.com • http://www.fekke.com/blog/ • twitter.com/davidfekke

  26. http://asp.net/mvc • Codeplex • http://weblogs.asp.net/scottgu/ • http://bit.ly/mvc-ebook • http://bit.ly/mvcmusicstore • Nuget

More Related