jaxdug march 2012. who am i david fekke web applications and ios apps jaxdug, jssug, jaxjug...

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

Upload: whitney-lamb

Post on 12-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

USING ASP.NET MVC3 W/ JQUERY

JaxDUG March 2012

Page 2: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

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: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

ASP.NET MVC 3.NET Framework

Page 4: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

JQUERY 1.7JavaScript Framework

Page 5: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and
Page 6: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and
Page 7: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

VALIDATION

Page 8: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

INTERACTIVITY

Page 9: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

AJAX

Page 10: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

WIDGETS AND UI

Page 11: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

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: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and
Page 13: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

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: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

<!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: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

<appSettings> <add key="ClientValidationEnabled"

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

Page 16: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

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: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

<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: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

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: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

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

PLEASE AVOID

$(sometag).live(fn);

Page 20: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

Event object functions

event.preventDefault(); event.stopPropagation(); event.stopImmediatePropagation();

Page 21: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

Partial Views

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

Page 22: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

Ajax

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

Page 23: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

Ajax function

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

Page 24: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

getJSON function

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

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

Page 25: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

JQueryUI

Dragging Widgets, Accordian, Tabs, Datepicker,

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

Page 26: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

3rd Party Jquery Grids

tableSorter jqGrid Flexigrid DataTables SlickGrid Ingrid

Page 27: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

DEMO

Page 28: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

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

Page 29: JaxDUG March 2012. Who am I  David Fekke  Web Applications and iOS Apps     JaxDUG, JSSUG, JaxJUG and

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