Bling-bling with MVC and jQueryBeing a pimp without SilverlightMaarten Balliauw	@maartenballiauwKris van der Mast	@KvdM
Who are we? – MaartenMaarten BalliauwAntwerp, Belgiumwww.realdolmen.comFocus on webASP.NET, ASP.NET MVC, PHP, Azure, VSTS, …MVP ASP.NEThttp://blog.maartenballiauw.behttp://twitter.com/maartenballiauw
Who are we? – KrisKris van der MastAntwerp, Belgiumwww.ordina.beFocus on web technologiesASP.NET, ASP.NET MVC, WCF, Silverlight, ...MVP for ASP.NETASP Insiderhttp://blog.krisvandermast.comhttp://www.twitter.com/KvdM
AgendaASP.NET WebFormsASP.NET MVCjQueryResourcesQ&A
ASP.NET MVCMega Very Cool?
The ASP.NET familyASP.NETDynamic Data & AJAXPresentationASP.NETWebFormsASP.NETMVCASP.NETCoreCore Runtime
ASP.NET WebForms
ASP.NET WebFormsTaken programming model from WinFormsFake stateful modelAutomatic testing is hard
ASP.NET MVCTestabilityControl over HTMLExtensibilityIt makes you thinkLearn new concepts“if you are allergic to porc,don’t go work in a sausage factory”
Model-View-Controller in ASP.NET MVCModel(“DTO” between C and V)Controller(Input)RequestResponseApplication LogicView(Presentation)
CharacteristicsMaintain Clean Separation of ConcernsEasy Testing Red/Green TDD Highly maintainable applications by defaultExtensible and PluggableSupport replacing any component of system
CharacteristicsEnable clean URLs and SEOSEO friendly URL structuresGreat ASP.NET integrationAll providers are supportedMembership, Caching, Session, …ASP.NET designer in VS2008/VS2010
New in ASP.NET MVC2...ValidationStrongly Typed HTML HelpersTemplated HTML HelpersAreasAsync Controllers
DEMOASP.NET MVC
jQueryWhat is jQuery?JavaScript Abstraction“LINQ to DOM”Why use jQuery?Making JavaScript and the DOM suck lessEasy to UseRich Plug-in EcosystemCross Browser Support
Money, money, money!$
The BasicsjQuery() and $()The ready() FunctionEffective when DOM is readyjQuery(document).ready(main);$(document).ready(main);$(document).ready(function() { … } );$(function()  { … } );function main() {    …}
jQuery BasicsjQuery WrappersjQuery Selectors$(selector)jQuery(selector)
SelectorsBasic Selectors#id.classelement	selector1,selector2,selectorN,…*$(this)
SelectorsOther Selector CategoriesFormAttributeHierarchyFilterContentChild
It gives you power!functionvalidateForm() {    var f = document.forms[0];    var atLeastOneChecked = false;for (var i = 0; i < document.forms[0].length; i++) {        var e = document.forms[0][i];if (e.type == "checkbox" && e.className == "group1" &&e.checked) {atLeastOneChecked = true;        }    }if (!atLeastOneChecked) {        alert("Please check at least one item!");    }    return atLeastOneChecked;}functionvalidateForm() {if ($(".group1:checked").length == 0) {alert("Please check at least one item!");        return false;}   return true;}
Unobtrusive JavaScriptStart with “plain old HTML”Layer on some CSS styling providing visual styleLayer on some JavaScript providing enhanced behaviour
EventsUnobtrusive JavaScriptCross Browser Support$(<selector>).eventname(<functionpointer> or inline);
Event BindingBinds events to matched sets$(selector).bind(“eventName",function);
ChainingPowerfulFluent$(selector).method$(selector).method({…}).method2({…});
Manipulating HTMLhtml()Gets/sets the innerHTML text()Gets/sets the innerTextMethod, not property syntaxOther Methodsappend() prepend()appendTo() prependTo()remove
Plug-insRich Plug-in EcosystemThousands availableDownloadable .js filesYou can create your ownhttp://jQuery.com/plugins
AjaxWeb ServicesWCFXMLHttpRequest$.ajax()
Ajax$.ajax({      type: "POST",      url: webMethod,      data: parameters,      contentType: "application/json; charset=utf-8",      dataType: "json",      success: function(msg) {                  $(selector).html(msg.d);      },      error: function(e){              $(selector).html(“error message");                                }});
DEMOWant to see it being used?
ResourcesLearn more!
Resourceshttp://www.jquery.comhttp://www.asp.net/mvchttp://jqueryui.com/demos/http://www.bing.comhttp://www.trirand.net/demoaspnetmvc.aspx
Questions?More information?http://asp.net/mvchttp://jquery.comContact us!http://blog.maartenballiauw.behttp://blog.krisvandermast.comThank you!

Being a pimp without silverlight - ASP.NET MVC 2 and jQuery

Editor's Notes

  • #11 MVC is a design pattern that stands for Model-View-Controller. What is strives to do is separate the concerns of an application’s presentation layer by assigning specific roles to the three different components.The Controller is responsible for handling all user input. Once input has been received, the Controller will perform any operations/actions it needs to, which might include interacting with the Model.The Model represents the core concern/logic of the application. Once the Controller retrieves some model data and performs any work with the model/etc it needs to it constructs a presentation model that describes the model in terms the View can understand.The View is the visual representation of the model. It presents the model data to the actual user in a way that is meaningful. In a web application, this would typically be HTML.With these three pieces in place, your presentation layer becomes cleanly separated in such a way that each component can be developed/tested independently.
  • #12 -Model has onepurpose-Controller has onepurpose-View really handles the view, no business logic in there!-Each part is replacable-Source code availableonCodePlex. Not open source, butenablesyou to buildyourown, private flavour
  • #13 -Usersexpect clean URLsnowadays-Notreplacing ASP.NET  built on top of it
  • #14 -Usersexpect clean URLsnowadays-Notreplacing ASP.NET  built on top of it