1 / 28

ASP.NET Dynamic Data

ASP.NET Dynamic Data. Marc Ziss Z Consulting marc@zconsulting.com. What is it?. Code Name 'Oryx' Web application scaffolding Easy to dynamically display pages based on the data model of the underlying database Easy to edit data for admin apps Helps in prototyping systems quickly

raziya
Télécharger la présentation

ASP.NET Dynamic Data

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. ASP.NET Dynamic Data Marc Ziss Z Consulting marc@zconsulting.com

  2. What is it? • Code Name 'Oryx' • Web application scaffolding • Easy to dynamically display pages based on the data model of the underlying database • Easy to edit data for admin apps • Helps in prototyping systems quickly • Out of the box simple to use or can be very customized

  3. What does it do ? • Uses LINQ to SQL to build a Data model. • Uses DynamicData Controls to build editable screens. • Builds in Paging, Sorting, Filtering, and Validation automatically. • Dynamic Data fields for rendering individual data types. • Allows a great deal of customization.

  4. Let's do it

  5. What do I need to use it? • ASP.NET 3.5 Extensions CTP (http://www.asp.net/Downloads/3.5-extensions) • Visual Studio 2008

  6. Products that are similar • Subsonic (free) • Django (free but Python) • ASP Runner • Iron Speed Designer

  7. What comes in the box? • ASP.NET 3.5 Extensions CTP has a lot in it • ASP.NET Dynamic Data • ADO.NET Data Services (formerly codename Astoria) • ASP.NET Model View Controller Applications • ASP.NET AJAX • Managing Browser History Using Server Controls • ASP.NET Silverlightcontols • ADO.NET Entity Framework

  8. Built in Dynamic Data Pages • ListTemplate.aspx - Grid to edit inline or call from a link to a detail page. • DetailsTemplate.aspx – Edit one record on a page. • ListDetailsTemplate – Both a grid and an a detail editor (default). • Same Routing engine as MVC.

  9. Let's look @ the templates + Web.config

  10. Dynamic View Controls • DynamicGridView • DynamicDetailsView • DynamicFormView • DynamicListView

  11. Dynamic controls • DynamicField - Automatically knows what mode Dynamic view is in (Edit, Item, Insert) for use with • DynamicGridView • DynamicDetailsView • DynamicControl, DynamicEditControl, and DynamicInsertControl – Dynamic fields to be used with templated view controls • Template columns in a DynamicGridView • DynamicFormView • DynamicListView

  12. Trick out my grid • Customizations as easy as making a new partial class. • Allows unique behavior for a particular table

  13. Formatting by decorating • DisplayFormat - formats for currency, dates, etc… • DisplayColumn – Allows a text column other than the 2nd column in the fk to describe the ID

  14. Demo using formatting attributes

  15. Validation by decoration • [Range("UnitsInStock",10,50, ErrorMessage="Must be between {1} and {2}")] • [Required("ContactName", ErrorMessage = "Contact name is required.")] • [Regex(“ssn", "[0-9][a-z][0-9]", ErrorMessage = "Needs to be formatted as 'number letter number'")]

  16. Demo using validation attributes

  17. Validation by notification • LINQ to SQL classes are generated with hooks for events that are normally not implemented • Lightweight event notification • New feature new to .NET 3.5 called partial methods • Like partial classes, but used to extend methods that may or may not be implemented in class instance (can be seen in Northwind.designer.cs)

  18. Demo validation using partial method

  19. Built in Control templates • By default Dynamic Data Fields try to match the rendering of a control with one of the built in Control Templates: • Boolean.ascx • Boolean_Edit.ascx • DateTime.ascx • DateTime_Edit.ascx • Integer_Edit.ascx • Decimal_Edit.ascx • Many More

  20. Replacing Built in Control templates • Simple .ascx files • When code is modified all controls behavior will be affected globally. • Can perform global validation here as well • Example Calendar

  21. Look @ the templates and modify one

  22. Customization by decoration • [RenderHint] enables you to build a custom control that can be explicitly linked to a field. • Simple as validation • Because it is a user control there can be multiple controls that can speak to each other. • Can use Ajax Toolkit to use helpful extenders right out of the box • Customized controls work regardless of which view is beieng used (i.e. DynamicGridView, DynamicListView, etc…)

  23. Make our own custom control (courtesy of David Ebbo)

  24. Look Ma; no PageTemplates!!! • Don’t have to work with a Page Template we can build stand alone pages that use dynamic data • Requires a little more work. • Need to make some manual changes…for now

  25. The ListView Rocks!!! • Newest template based control has dynamic counterpart. • Has the benefits of a GridView, but allows full control of rendering. • Interesting wizards to help setup the template in interesting ways.

  26. Roll our own ListView Page

  27. Links • David Ebbo: http://blogs.msdn.com/davidebb/archive/2007/12/12/dynamic-data-screencast-is-now-available.aspx • Brad Abrams: http://blogs.msdn.com/brada/archive/2007/12/13/asp-net-3-5-extensions-all-about-dynamic-data.aspx • David Hayden: http://davidhayden.com/blog/dave/ • Scott Guthrie: http://weblogs.asp.net/scottgu/archive/2007/12/14/new-asp-net-dynamic-data-support.aspx

  28. Q +A

More Related