techdays 2013 jari kallonen: what's new webforms 4.5
TRANSCRIPT
![Page 1: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/1.jpg)
Régis Laurent Director of Operations, Global Knowledge Competencies include: Gold Learning Silver System Management
ASP.NET WebForms 4.5 uudet piirteet
Jari Kallonen Software Specialist at Tieturi Oy
![Page 2: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/2.jpg)
Régis Laurent Director of Operations, Global Knowledge Competencies include: Gold Learning Silver System Management
- Strongly Typed Data Controls
- Model Binding - HTML Encoded
Data-Binding Expressions
- Unobtrusive Validation
- HTML5 tuki - Muuta sälää
![Page 3: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/3.jpg)
Tyypitetty Data Bindings
<div> <asp:Repeater ID="CustomerRepeater" runat="server" ItemType="Demoilua.Model.Henkilo"> <ItemTemplate> <li> ID:<%# Item.ID %> Nimi:<%# Item.Nimi %> Puhelin:<%# Item.Puhelin %> </li> </ItemTemplate> </asp:Repeater> </div>
![Page 4: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/4.jpg)
Model Binding – Tiedon valinta
public IEnumerable<Demoilua.Model.Henkilo> GetData() { return Demoilua.Model.HenkiloRepository.HaeKaikki(); }
<div> <asp:Repeater ID="CustomerRepeater" runat="server" ItemType="Demoilua.Model.Henkilo” SelectMethod="GetData"> <ItemTemplate> <li> ID:<%# Item.ID %> Nimi:<%# Item.Nimi %> Puhelin:<%# Item.Puhelin %> </li> </ItemTemplate> </asp:Repeater> </div>
![Page 5: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/5.jpg)
Value Providers - QueryString
public IQueryable<Customer> GetCustomers( [QueryString]string keyword) { return CustomerRepository.GetByName(keyword); }
![Page 6: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/6.jpg)
Value Providers - Kontrollit
public IQueryable<Customer> GetCustomers( [Control("customers")]int? id) { if (id.HasValue) return CustomerRepository.GetOne(id); else return CustomerRepository.GetAll(); }
![Page 7: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/7.jpg)
Value Provider vaihtoehtoja
• Controls • Query string values • View Data • Session State • Cookies • Posted Form data • View State • Custom
![Page 8: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/8.jpg)
2-suuntainen Binding
<EditItemTemplate> ID:<asp:TextBox ID="IDTextBox" runat="server" Text='<%# BindItem.ID %>' /> LastName:<asp:TextBox ID="NimiTextBox" runat="server" Text='<%# BindItem.Nimi %>' /> Puhelin:<asp:TextBox ID="PuhelinTextBox" runat="server" Text='<%# BindItem.Puhelin %>' /> </EditItemTemplate>
![Page 9: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/9.jpg)
Demo
Binding, Value Providers
![Page 10: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/10.jpg)
Markup based validointi
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="nimiTextBox" ErrorMessage="Nimi puuttuu" ForeColor="Red" />
![Page 11: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/11.jpg)
Unobtrusive (”huomaamaton”) validointi
Pienentää sivun kokoa vähentämällä inline Javacript koodin käyttöä ->Käyttää HTML5 data-* attribuutteja • ValidationSettings:UnobtrusiveValidationMode • Asetus: – Web.Config – Global.asax – Page luokka
![Page 12: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/12.jpg)
javascript validointi
![Page 13: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/13.jpg)
Unobtrusive validointi
Edellinen ”Unobstrusive” muodossa
![Page 14: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/14.jpg)
Data annotaatiot Model luokassa
public class Henkilo { [Key] public int ID { get; set; } [Required] public string Nimi { get; set; } [Range(0, 130)] public int Ika { get; set; } [Phone] public string Puhelin { get; set; } [EmailAddress, StringLength(256)] public string Email { get; set; } }
![Page 15: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/15.jpg)
Joitain Data Annotaatioita
• CreditCard • Phone • EmailAddress • Range • Compare • Url • FileExtensions • Required • Key • RegularExpression
![Page 16: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/16.jpg)
Model luokan validointi
public void SaveCustomer(Customer customer) { if (ModelState.IsValid) { using (var db = new Demoilua.Model.ProductsContext()) { db.Customers.Add(customer); db.SaveChanges(); Response.Redirect("~/Customers.aspx"); } } }
![Page 17: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/17.jpg)
Validointikontrollit
<asp:ValidationSummary runat="server" ShowModelStateErrors="true" ForeColor="Red" HeaderText="Please check the following errors:" /> <asp:ModelErrorMessage ModelStateKey="phone" runat="server" ForeColor="Red" />
![Page 18: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/18.jpg)
Tulos:
![Page 19: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/19.jpg)
Demo
Validointi
![Page 20: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/20.jpg)
Request validointi
• Korvaa tarvittaessa HttpEncoderin • Auttaa suojautumaan cross-site scripting (XSS) ja LDAP injection hyökkäyksiltä • AntiXSS libraryssa – HtmlEncode, HtmlFormUrlEncode,HtmlAttributeEncode – XmlAttributesEncode, XmlEncode – UrlEncode , UrlPathEncode – CssEncode
![Page 21: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/21.jpg)
4.5 Request validointi
<system.web> … <httpRuntime encoderType="System.Web.Security.AntiXss.AntiXssEncoder" /> </system.web>
![Page 22: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/22.jpg)
Tuki await/async ja Task pohjaisille pyynnöille
• HTTP Modules EventHandlerTaskAsyncHelper TaskEventHandler • HTTP Handlers HttpTaskAsyncHandler
![Page 23: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/23.jpg)
Async tuki
• Web.config <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/> • Page directive <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ProductDetails.aspx.cs" Inherits="WebFormsLab.ProductDetails" Async="true" %>
![Page 24: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/24.jpg)
Async Task esimerkki
RegisterAsyncTask(new PageAsyncTask(async (t) => { using (var wc = new WebClient()) { //aikaisemmin wc.DownloadFile await wc.DownloadFileTaskAsync( imageUrl, Server.MapPath(product.ImagePath)); } }));
![Page 25: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/25.jpg)
HTML5 päivityksiä
• TextBox TextMode – Tukee email, datetime tyyppejä jne. • FileUpload – tuki useammalle upload tiedostolle – Selainriippuvainen • Validointikontrollit tukee HTML5 elementtejä • runat=“server” lisäksi URL osoite –<video runat=“server” src=“~/file.wmv”/>
![Page 26: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/26.jpg)
ASP.NET Core päivityksiä
• WebSockets Protocol (IIS8) • Javascriptin ja CSS:n pakkaus (Bundling / Minification) • Suorituskyky – Yhteisten komponenttien jako (muistin kulutus) – Multi-core JIT käännös – Garbage Collection – Web sovellusten esilataukset
![Page 27: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/27.jpg)
Javascriptin ja CSS:n pakkauksen määrittely
using System.Web.Optimization; //… public class BundleConfig { public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}.js")); bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include( "~/Scripts/jquery-ui-{version}.js")); bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( "~/Scripts/jquery.unobtrusive*", "~/Scripts/jquery.validate*")); bundles.Add(new ScriptBundle("~/bundles/WebFormsJs").Include( "~/Scripts/WebForms/WebForms.js", "~/Scripts/WebForms/WebUIValidation.js", "~/Scripts/WebForms/MenuStandards.js", "~/Scripts/WebForms/Focus.js", "~/Scripts/WebForms/GridView.js“); } }
![Page 28: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/28.jpg)
Visual Studio 2012 parannuksia
HTML Editor Smart Tasks, loppu/alku elementin päivitys HTML 5 snippets, parempi Intellisense, … http://www.asp.net/vnext/overview/whitepapers/whats-new#_Toc303354490 JavaScript Editor Code outlining, Go to Definition, … http://www.asp.net/vnext/overview/whitepapers/whats-new#_Toc303354500 CSS Editor Color Picker, CSS 3 support, custom region (/*#region Menu */ … /*#endregion */ http://www.asp.net/vnext/overview/whitepapers/whats-new#_Toc303354508
![Page 29: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/29.jpg)
Yhteenveto
Model pohjainen binding Validointi Laajentunut Html 5 tuki Async/Await ja Task –pohjaiset toiminnot Suorituskykyä Coreen
![Page 30: TechDays 2013 Jari Kallonen: What's New WebForms 4.5](https://reader036.vdocuments.us/reader036/viewer/2022062405/55838dcdd8b42a282c8b4f33/html5/thumbnails/30.jpg)
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentations. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Kiitos ja kumarrus [email protected]