rad web applications with asp.net dynamic data

16
RAD Web Applications with ASP.NET Dynamic Data Ingo Rammer [email protected]

Upload: pravat

Post on 22-Feb-2016

37 views

Category:

Documents


0 download

DESCRIPTION

RAD Web Applications with ASP.NET Dynamic Data. Ingo Rammer [email protected]. Ingo Rammer and thinktecture . Support and consulting for software architects and developers Application Optimization, Troubleshooting, Debugging Architectural Consulting and Prototyping - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: RAD Web Applications with ASP.NET Dynamic Data

RAD Web Applications with ASP.NET Dynamic DataIngo [email protected]

Page 2: RAD Web Applications with ASP.NET Dynamic Data

Ingo Rammer and thinktecture

• Support and consulting for software architects and developers

Application Optimization, Troubleshooting, DebuggingArchitectural Consulting and PrototypingDeveloper-Coaching and -MentoringArchitecture and Code Reviews

• http://www.thinktecture.com• [email protected]

Page 3: RAD Web Applications with ASP.NET Dynamic Data

ASP.NET Dynamic Data• Customizable model/class-driven

frontend technologyToday: Linq-to-SQL and Entity FrameworkScaffoldingHighly customizable

• But more important:Dynamic Data Controls

Page 4: RAD Web Applications with ASP.NET Dynamic Data

Customizable Scaffolding• Scaffolding – Automatic Form Generation• Customizable UI („No Limits“ – it‘s

all .NET)• Configurable MVC-style URL routing• Default: Querystring, but can be

changed to routing like:http://server/Customershttp://server/Customers/ALFKIhttp://server/Customers/ALFKI/Edit... or any other routing you can imagine

Page 5: RAD Web Applications with ASP.NET Dynamic Data

Extensibility• Extension Model for logical schema

(Entity Framework or Linq-to-SQL)ValidationBusiness Rules

• Sorting, Filtering, Edit, Insert, Delete• .NET Framework 3.5 SP1 (+ Hotfix)

Page 6: RAD Web Applications with ASP.NET Dynamic Data

Scaffolding• The first thing you‘ll see at every

demoZero code data forms (but still: customizable whenever you want!)Simply uncomment the following line

• This enables scaffolding for all entities

// Global.asax in Application_Start

model.RegisterContext (typeof(NorthwindEntities), new ContextConfiguration() { ScaffoldAllTables = true });

Page 7: RAD Web Applications with ASP.NET Dynamic Data

Restricted Scaffolding• Attributes on a class-level or field

level• Field level supports metadata-

redirection with [MetadataType][ScaffoldTable(true)][MetadataType(typeof(ProductsMetaData))]public partial class Products{}

public class ProductsMetaData{ [ScaffoldColumn(true)] public object Name;}

Page 8: RAD Web Applications with ASP.NET Dynamic Data

Customizating Templates• Templates

Page Templates („all List Pages“, „all Detail pages“)Field Templates („all Integer TextBoxes“)

• Custom PagesUse a particular ASP.Net page for List,Detail,Edit and/or Insert

Can be done globally or configured with routingCan use DynamicField/DynamicControl with UIHints on them

Page 9: RAD Web Applications with ASP.NET Dynamic Data

Creating a Custom Page• Simply create a folder in CustomPages

named like your entity and copy/paste one of the existing ASPX pages

• Create a folder name with the exact same name as your entity class

• Copy and paste the desired ASPX file from PageTemplates to CustomPages/EntityName

• Done! (no configuration necessary)

Page 10: RAD Web Applications with ASP.NET Dynamic Data

Sample Custom Page<asp:DetailsView DataSourceID="DetailsDataSource" AutoGenerateRows="false"> <Fields> <asp:DynamicField DataField="ProductName" /> <asp:DynamicField DataField="QuantityPerUnit" HeaderText ="Quantity" /> <asp:DynamicField DataField="UnitPrice" /> <asp:DynamicField DataField="UnitsInStock" /> <asp:DynamicField DataField="Categories" /> <asp:TemplateField> <HeaderTemplate>Name</HeaderTemplate> <ItemTemplate> Templated: <asp:DynamicControl

runat="server" DataField="ProductName" /> </ItemTemplate> </asp:TemplateField> </Fields><asp:DetailsView>

Page 11: RAD Web Applications with ASP.NET Dynamic Data

Customizing the Model• [UIHint]: Use a certain control for a field • [DataType]: custom type (it’s just a string) which

can later be used by the field template („EmailAddress“, „Url“)

• [DisplayFormat]: Use a certain format string for one field

• [DisplayField]: Use this column for foreign key values of this table (ex: display the field „Name“ for Customers)

• And more: Whatever you want/need to later check in a custom input control. Create custom Attributes as needed

Page 12: RAD Web Applications with ASP.NET Dynamic Data

Custom Fields• Create a ASCX in /FieldTemplates,

derive from FieldTemplateUserControl and override DataControl

• Possible: Override FormatFieldValue, ExtractValuesUse MetaDataAttribute. TypeOf<T>() to get access to attributes defined on the field in the model

Page 13: RAD Web Applications with ASP.NET Dynamic Data

Embedding DD• Using DynamicData on an unrelated

ASPX page• Hint: It's just like the custom page!• Create a DataSource, Parameters,

DetailView, GridView or ListView and you're ready to go ...

Page 14: RAD Web Applications with ASP.NET Dynamic Data

In-Depth Customization• There are hardly any limits, DD fits

very nicely with ASP.NET• You‘ve already seen: custom fields,

custom pages• Missing pieces is: which fields get

displayed, in what order?• IAutoFieldGenerator: specifies which

fields should be displayed

Page 15: RAD Web Applications with ASP.NET Dynamic Data

Future• Preview can be downloaded

(ASP.NET Dynamic Data 4.0 Preview 2)

• Different data access layersASP.NET Data Services & custom data layers

• Query BlocksFiltering with LINQ Expressions

• Additional Field Templates (Enum, Email, Url)

Page 16: RAD Web Applications with ASP.NET Dynamic Data