29
USING ASP.NET MVC3 W/ JQUERY JaxDUG March 2012

Using ASP.NET MVC3 w/ JQuery

  • Upload
    mauve

  • View
    58

  • Download
    0

Embed Size (px)

DESCRIPTION

JaxDUG March 2012. Using ASP.NET MVC3 w/ JQuery. Who am I. David Fekke Web Applications and iOS Apps http://fekke.com/blog/ JaxDUG , JSSUG, JaxJUG and JaxFusion David Fekke L.L.C. .NET Framework. ASP.NET MVC 3. JavaScript Framework. Jquery 1.7. Validation. Interactivity. - PowerPoint PPT Presentation

Citation preview

Page 1: Using ASP.NET MVC3 w/  JQuery

USING ASP.NET MVC3 W/ JQUERY

JaxDUG March 2012

Page 2: Using ASP.NET MVC3 w/  JQuery

Who am I David Fekke Web Applications and iOS Apps http://fekke.com/blog/ JaxDUG, JSSUG, JaxJUG and

JaxFusion David Fekke L.L.C.

Page 3: Using ASP.NET MVC3 w/  JQuery

ASP.NET MVC 3.NET Framework

Page 4: Using ASP.NET MVC3 w/  JQuery

JQUERY 1.7JavaScript Framework

Page 5: Using ASP.NET MVC3 w/  JQuery
Page 6: Using ASP.NET MVC3 w/  JQuery
Page 7: Using ASP.NET MVC3 w/  JQuery

VALIDATION

Page 8: Using ASP.NET MVC3 w/  JQuery

INTERACTIVITY

Page 9: Using ASP.NET MVC3 w/  JQuery

AJAX

Page 10: Using ASP.NET MVC3 w/  JQuery

WIDGETS AND UI

Page 11: Using ASP.NET MVC3 w/  JQuery

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 Json ActionResult

Page 12: Using ASP.NET MVC3 w/  JQuery
Page 13: Using ASP.NET MVC3 w/  JQuery

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

Page 14: Using ASP.NET MVC3 w/  JQuery

<!DOCTYPE html><html>

<head><title>@ViewBag.Title</title>@RenderSection(“StyleSection”, false)

<head><body>

… Rest of your html body here …@RenderSection(“Scripts”, false)

<body><html>

Page 15: Using ASP.NET MVC3 w/  JQuery

<appSettings> <add key="ClientValidationEnabled"

value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> </appSettings>

Page 16: Using ASP.NET MVC3 w/  JQuery

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; } }

Page 17: Using ASP.NET MVC3 w/  JQuery

<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="" />

Page 18: Using ASP.NET MVC3 w/  JQuery

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));

Page 19: Using ASP.NET MVC3 w/  JQuery

<sometag onclick=“fn();” />

PLEASE AVOID

$(sometag).live(fn);

Page 20: Using ASP.NET MVC3 w/  JQuery

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

Page 21: Using ASP.NET MVC3 w/  JQuery

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

Page 22: Using ASP.NET MVC3 w/  JQuery

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

Page 23: Using ASP.NET MVC3 w/  JQuery

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

Page 24: Using ASP.NET MVC3 w/  JQuery

getJSON function$.getJSON(“/mycontroller/myAction/232”, function(data) { … });

public ActionResult SampleJsonResponse(int Id){ int mynumber = providerGetNumber(Id); return Json(mynumber, JsonRequestBehavior.AllowGet);}

Page 25: Using ASP.NET MVC3 w/  JQuery

JQueryUI Dragging Widgets, Accordian, Tabs, Datepicker,

Dialog, Slider and Autocomplete Utilities Widget framework Effects Grid control coming

Page 26: Using ASP.NET MVC3 w/  JQuery

3rd Party Jquery Grids tableSorter jqGrid Flexigrid DataTables SlickGrid Ingrid

Page 27: Using ASP.NET MVC3 w/  JQuery

DEMO

Page 28: Using ASP.NET MVC3 w/  JQuery

How to Contact Me [email protected] http://www.fekke.com/blog/ twitter.com/davidfekke

Page 29: Using ASP.NET MVC3 w/  JQuery

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