Welcome to MSDN Blogs Sign in | Join | Help

Dynamic Data Preview 4 Released

Today we released the newest preview release of Dynamic Data. You can view the details and download this release from here: http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=27026.

 

The preview releases of Dynamic Data contain much of the new feature sets that will be available when we release .NET 4. The cool thing is you can start using a lot of the new features against .NET 3.5 SP1 now using these releases.

 

When we look back and see how people view Dynamic Data we regret that people immediately think of it as scaffolding of data. This is something that it does do, and I think it does a pretty good job at it. But Dynamic Data is a lot more then that, providing a new templating mechanism called Field Templates which allow the default markup for many of our built in data controls to be more easily customized. These field templates also support validation by default (something our rich data controls did not) which can be customized by adding metadata to data objects.

 

In the past to enable Dynamic Data functionality in a web application the application needed to follow a couple of rules:

- It had to have a data model such as Entity Framework or Linq to SQL

- The data model had to be registered at startup in Global.asax

- The DynamicData directory had to exist in the web application

 

One of the new features this new preview release supports is adding field templates and validation to any ASP.NET web page without having to meet these requirements. It is as simple as:

 

GridView1.EnableDynamicData(typeof(Product));

 

What does this do for you? Today a control like GridView supports all kinds of high level features such as paging, sorting, viewing, editing but it provides no validation of data at all. So if your database has an integer field the end user would be able to type any data they wanted and when saving the record an ASP.NET yellow screen of death screen would appear (on the development box) saying that the data could not be converted to an integer. By enabling Dynamic Data automatic validation will occur because validation is built into the field templates that would render the column and a nice error message will appear in the page saying “Field XYZ must be an integer”.

 

To see this in action download the preview release and try out the SimpleDynamicDataSample.

Posted by scothu | 15 Comments
Filed under: ,

ASP.NET 4.0 and Visual Studio 2010 Development Overview & Dynamic Data

Last week at the Mix conference in Las Vegas we released a whitepaper that contain a list of many of the items that we are adding to ASP.NET 4.0 and Visual Studio 2010. The paper provides an overview of what we expect to be in the first beta release (do not ask for timeframes as we do not have a published date yet). You can view the whitepaper here in both HTML and download form: http://www.asp.net/learn/whitepapers/aspnet40/

 

Lasr week we also released a new preview of Dynamic Data. You can download the preview 3 of Dynamic Data from this link: http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24887. This preview really rocks and contains the QueryBlockExtender mentioned in the whitepaper above it also includes a new DomainDataSouce for accessing business layers that are created from the new .NET RIA Services CTP that was also released at Mix. Check it out and I hope to blog on it soon.

 

Today I will be speaking at DevConnection in Orlando, FL on Data Access and WebForm improvements in 4.0. If you are at the show the two talks are:

 

2pm: AMS06: ASP.NET 4.0 Data Access Patterns for Success with Web Forms

3:45: AMS08: ASP.NET Web Forms 4.0

 

Hope to see you there!

Posted by scothu | 8 Comments
Filed under: ,

Better support for 3rd party controls and Dynamic Data in ASP.NET 4.0 and DevExpress Grid and Dynamic Data

One of the things that we worked on supporting in Dynamic Data is the ability for third party controls like Grids to be able to host DynamicControls. Basically allowing the developer to use controls that are fancier or have more features then the stock controls in ASP.NET with Dynamic Data.

For the first version of Dynamic Data we tried we ran into various limitations because it was delivered in a service pack which limited what type of changes we could make in the framework. Basically we were able to add new API’s but had little ability to change existing API’s.

One of the limitations this placed on controls was that to support Dynamic Data they would need to derive from DataBoundControl because there were no interfaces that controls could implement to indicate that supported basic data binding operations. Some control vendors want to be able to derive their controls from Control to make them as lightweight as possible and to have the best performance.

To solve this in .NET 4.0 we are adding new interfaces that controls can implement that indicate that they do databinding and also indicate whether the control displays a single item or a list of items. Here is a breakdown of the new interfaces:

 

public interface IDataBoundControl

Interface for accessing the common properties for data bound controls.

string DataSourceID { get; set; }

Gets or sets the ID of the control from which the data-bound control retrieves its list of data items.

IDataSource DataSourceObject { get; }

Gets the actual data source control when DataSourceId is set.

object DataSource { get; set; }

Gets or sets the object from which the data-bound control retrieves its list of data items.

string[] DataKeyNames {get; set; }

Gets or sets an array that contains the names of the primary key fields for the items displayed in a control.

DataBoundControlMode Mode { get; }

Gets whether the control is in ReadOnly, Edit or Insert mode.

string DataMember { get; set; }

Gets or sets the name of the list of data that the data-bound control binds to, in cases where the data source contains more than one distinct list of data items.

 

public interface IDataBoundListControl

Interface for data bound controls that display multiple rows and can selection.

DataKeyArray DataKeys { get; }

Gets a collection of DataKey objects that represent the data key value of each row in a GridView control.

DataKey SelectedDataKey { get; }

Gets the DataKey object that contains the data key value for the selected row in a GridView control.

int SelectedIndex { get; set; }

Gets or sets the index of the selected row in a GridView control.

string[] RowClientIDSuffix { get; set; }

 

bool EnablePersistedSelection { get; set; }

Gets or sets whether the selection is based on index or on data keys.

 

IDataBoundItemControl

Interface for data bound controls that display a single item.

DataKey DataKey { get; }

Gets a DataKey object that represent the data key value of the row in a control.

 

IFieldControl

Interface for data bound controls that can automatically generate their fields based on data.

IAutoFieldGenerator FieldsGenerator { get; set; }

Gets and sets the IAutoFieldGenerator which generates the fields.

 

IDataBoundControl is implemented by a control to indicate that it support data binding. This includes datasources, primary keys and the mode the control operates in. IDataBoundListControl indicates a control that displays data in a list and supports selection. IDataBoundItemControl indicates a control that displays a single record at a time. And IFieldControl is for controls like GridView or DetailView that have the ability to autogenerate their columns. These new interfaces are implemented across all the standard data controls in 4.0 including ListView, GridView, DetailsView and FormView. If third party controls support these interfaces they will be usable with Dynamic Data.

One of the control vendors DevExpress has recently implemented Dynamic Data support without these interfaces in their grid control. Here is a very cool screencast by Mehul Harry that demonstrates their grid and Dynamic Data in action. With these new interfaces they will be able to support their spreadsheet control as well once 4.0 ships. View the screencast here: http://community.devexpress.com/blogs/aspnet/archive/2009/02/01/asp-net-dynamic-data-and-devexpress-grid.aspx. Please check it out and let Mehul know what you think!

Posted by scothu | 3 Comments
Filed under: ,

Update for .NET 3.5 SP1 Released

There was an update to the .NET 3.5 SP1 release a couple of days ago and I have not seen a lot of mention to it so thought I would write a blog post and talk about how this update affects ASP.NET.

First off you can search for KB959209 in the Microsoft knowledge base for details on this update. Here is the direct URL to the article: http://support.microsoft.com/kb/959209.

This update corrects the following issues that may affect an ASP.NET developer that has .NET 3.5 SP1 installed:

- Dynamic Data used with Entity Framework generates an error when navigating one to one relationships

- BrowserCaps generates an error if Front Page Server extensions are installed.

- Using a derived UpdateProgress control may encounter an exception.

- An exception is thrown if the website is using WPF to generate images and the site is hosted under IIS.

There are other issues that are fixed in the framework and CLR that could affect applications so I suggest reading the list of changes in the knowledge base.

If you are using Dynamic Data and Entity Framework then I highly recommend this update.

Posted by scothu | 6 Comments
Filed under: ,

Posting from Oredev in Sweden

Eilon Lipton and I have spent the week in Malmo, Sweden at the the Oredev conference. Here is the schedule of our talks:

 

November 19th – Get to Know the ASP.NET MVC Framework

November 20th – ASP.NET 4.0 Roadmap

November 20th – Advanced ASP.NET MVC

November 21st – ASP.NET Dynamic Data

 

Jonathan Carter has posted a great series of blogs posts on Dynamic Data. Check them out here:

Dynamic Data: Come For The Scaffolding, Stay For Everything Else
Dynamic Data: Kickin’ It Old School
Dynamic Data: Models, MetaModels And Everything In Between
Dynamic Data: The Little MetaModel That Could

Posted by scothu | 1 Comments

Securing Dynamic Data

One of the questions we often get is how do you secure Dynamic Data websites. Michael Miele one of the technical writers that writes the documentation for ASP.NET wrote a great sample that shows how to do this using Form Authentication and Roles that are provided in ASP.NET. We uploaded his sample to the Dynamic Data Samples Site last night and I thought I would share it out. Click HERE to go to the sample page and scroll down to the section “Secure Dynamic Data”. Enjoy!

Posted by scothu | 1 Comments

PDC ASP.NET Content Available Now

Just got back from PDC 2008 last week, we showed all kinds of cool new stuff. Here is a list of links for the videos of all the ASP.NET sessions:

 

ASP.NET 4.0 Roadmap - http://channel9.msdn.com/pdc2008/PC20/

ASP.NET MVC: A New Framework for Building Web Applications - http://channel9.msdn.com/pdc2008/PC21/

Microsoft Visual Studio: Web Development Futures - http://channel9.msdn.com/pdc2008/TL48/

Web Application Packaging and Deployment - http://channel9.msdn.com/pdc2008/ES15/

ASP.NET Dynamic Data - http://channel9.msdn.com/pdc2008/PC30/

ASP.NET: Cache Extensibility - http://channel9.msdn.com/pdc2008/PC41/

 

We also released new preview bits of Dynamic Data for PDC. You can check out the new bits from here: Dynamic Data Preview 1.

 

I’m also excited that David Ebbo has blogged an early version of support for many to many relationships in Entity Framework for Dynamic Data. You can see grab the code and use it with today's Dynamic Data. You can view the post: HERE.

Posted by scothu | 1 Comments

Image Generation is released to CodePlex

I'm really happy to announce that earlier this week we released a new feature called Image Generation to the ASP.NET CodePlex site. You can get a link directly to the page supporting this feature by clicking on: http://www.codeplex.com/aspnet/Wiki/View.aspx?title=WebForms&referringTitle=Home.

 

There was a feature that was in Beta 1 for Visual Studio 2005 (Whitbey) called DynamicImage that provided a control for generating images and an image service for serving them. This feature was sadly cut because some of the other parts of the framework it depended on were cut.

 

Image Generation is basically work to bring this type of feature back into the framework. Here are some of the highlights of what this new feature does:

 

New GeneratedImage ASP.NET control. This control is a derivative of asp:Image control that supports being hooked up to an Image Handler and passing parameters to it. If you put this control on a page and go into design mode it will have chrome attached to it that when clicked will automatically generate an ImageHandler and wire the control to the URL of the ImageHandler. Parameters such as the primary id and timestamp can be databound to the control and will automatically be passed to the handler.

 

ImageHandler which is an implementation of IHttpHandler that provides support for many image based things:

  • Transforms (resizing, watermarks, user defined transforms)
  • Client-side caching
  • Server side caching
  • Access to parameters passed from the GeneratedImage control
  • Provide simple mechanics for returning images

 

If you click to the site there are three samples of how to use GeneratedImage:

  • Simple Generated Image - this shows how you would create a simple bitmap and return it
  • Databased Images - shows how you would use this feature to display images that are stored in a database
  • Custom Image Transforms - shows how to write a custom image transform that adds a ASP.NET logo to an image

We are considering adding this feature in the next version of .NET and would love feedback. Please download and try and it out and let us know what you think!

Posted by scothu | 7 Comments

Workaround for Dynamic Data Entity Framework Posted

Today we posted a beta update to solve a couple of problems with Dynamic Data and Entity Framework that are in the RTM version of .NET 3.5 SP1. The main issue is a slight mis-match in the names that Dynamic Data looks for in Entity Framework and the names that Entity Framework is actually exposing. When this problem occurs an error that looks like "A property with name 'XX.Id' does not exist in metadata for entity type 'XX.XX.XXXX'".

 

Luckily we made the data model providers which are classes that look at data model and tell Dynamic Data what the tables, columns, names, etc are a extensible system. This means we can distribute a replacement data model provider that solves the issue I mentioned above. You can download a replacement Entity Framework provider at this link: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=16367

If you are running into this issue please download the fix above and let us know if it solves your issues.

Posted by scothu | 3 Comments

Dynamic Data RTM is Released!

Today we shipped .NET 3.5 SP1 which includes Dynamic Data. This means that the Dynamic Data RTM release is now available. Here are the links to download the final versions:

Visual Studio 2008 SP1 (also includes .NET 3.5 SP1): http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&displaylang=en

.NET 3.5 SP1 Standalone Installer: http://www.microsoft.com/downloads/details.aspx?FamilyId=AB99342F-5D1A-413D-8319-81DA479AB0D7&displaylang=en

 

You can also preview some of the upcoming changes and new features we are working on for Dynamic Data 2.0 and Dynamic Data MVC. You can view these on our page on the Codeplex site. You can view the ASP.NET page on Codeplex here: http://www.codeplex.com/aspnet. Click the Dynamic Data link to see all of our preview releases.

Posted by scothu | 3 Comments

Many Updates on Dynamic Data

This week at Redmond we have the ASP.NET Insiders up here where we show them a bunch of the new stuff we are working on. I'm happy to announce that we have many new update for Dynamic Data that are available today:

1) Dynamic Data Runtime and Dynamic Data Wizard - this has been updated with a much newer version of the Dynamic Data Wizard which have over 30 bug fixes. This is a wizard that provides many options for which tables to show, which modes to show them (read only/read write, etc) and allows multiple tables in the same page. All of the generated code uses features from the new Dynamic Data feature.

2) Dynamic Data Futures - this is a sample project that shows off many of the cool directions we are looking at for the next version of Dynamic Data. An example of some of these features are: ADO.NET Data Services (formerly known as Astoria), ObjectDataSource, binding and validation for plain old CLR objects (POCO), metadata for ordering columns,  adding metadata at runtime, support for images, advanced filtering including cascading and much more.

3) Dynamic Data for MVC Preview - we are working to support Dynamic Data on the new ASP.NET MVC framework as well. This is an EARLY release of this support. Compared to the WebForm version this has the current limitations: Only supports Linq to SQL, does not have client side validation and does not have filters on the list pages. Futures releases will address each of these items plus provide much more.

Posted by scothu | 3 Comments

Interview with Craig Shoemaker Posted

Last week I had a great chat with Craig Shoemaker on Dynamic Data. We talked about using Dynamic Data in existing applications, some about our new Futures release and some about upcoming work on having an MVC version of Dynamic Data. You can check out the interview on Pixel8 by clicking here: Craig Shoemaker interview

Posted by scothu | 1 Comments

How to add Dynamic Data to an Existing Web Application

Yesterday I posted about how to add Dynamic Data to an existing website and I got some feedback about how to add Dynamic Data to an existing web application. Web application projects work a little different the website projects, you can check out the differences here: http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx.

1) Create a dummy Dynamic Data web application project. Copy the DynamicData directory from it into your existing web application. You should also copy the Site.css and Site.master files. The Default.aspx file is optional, it display a menu of tables in your data model, this file is only needed if you plan on having such a menu in your application. IMPORTANT: Web application projects have namespaces in their code behind files, you may want to change the namespaces of the copied in files to match the namespace of your existing project. 

2) You can copy the Global.asax file or if you already have such a file you can just add the model registration and url routes as below to the

<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="System.Web.DynamicData" %>

void Application_Start(object sender, EventArgs e) {

MetaModel model = new MetaModel();

model.RegisterContext(typeof(YourDataContextType), new ContextConfiguration() { ScaffoldAllTables = false });

routes.Add(new DynamicDataRoute("{table}/{action}.aspx") {
    Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
    Model = model
});

}

3) Right click on the References node in the solution explorer and select "Add Reference". In the dialog that opens up you need to select System.ComponentModel.DataAnnotations, System.Web.Abstractions, System.Web.DynamicData and System.Web.Routing.

4) In the <compilation> section in web.config add the following assemblies:

<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.ComponentModel.DataAnnotations, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.DynamicData, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

5) In the <pages>/<controls> section add the following new tag prefix:

<add tagPrefix="asp" namespace="System.Web.DynamicData" assembly="System.Web.DynamicData, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

6) Enable the new ASP.NET Routing feature:

IIS 5/6/Casini

In the <httpModules> section add the following new module:

<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

IIS 7

In the <system.webServer>/<modules> section add the following:

<remove name="UrlRoutingModule" />

<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

In the <system.webServer>/<handlers> section add the following:

<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

 

At this point Dynamic Data should be functional. To enable it see the steps at the bottom of yesterdays post.

Posted by scothu | 8 Comments

How to add Dynamic Data to an Existing Web Site

I've had various people ask me if Dynamic Data can be added to an existing website and I've compiled a list of steps to do this. We hope to add a tooling gesture to Visual Studio in the future to automatically do these steps. Once these steps are complete you can start taking advantage of Dynamic Data functionality in your existing applications.

1) Create a dummy Dynamic Data Website project. Copy the DynamicData directory from it into your existing website. You should also copy the Site.css and Site.master files. The Default.aspx file is optional, it display a menu of tables in your data model, this file is only needed if you plan on having such a menu in your application.

2) You can copy the Global.asax file or if you already have such a file you can just add the model registration and url routes as below to the

<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="System.Web.DynamicData" %>

void Application_Start(object sender, EventArgs e) {

MetaModel model = new MetaModel();

model.RegisterContext(typeof(YourDataContextType), new ContextConfiguration() { ScaffoldAllTables = false });

routes.Add(new DynamicDataRoute("{table}/{action}.aspx") {
    Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
    Model = model
});

}

 

3) In the <compilation> section in web.config add the following assemblies:

<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.ComponentModel.DataAnnotations, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.DynamicData, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

 

4) In the <pages>/<controls> section add the following new tag prefix:

<add tagPrefix="asp" namespace="System.Web.DynamicData" assembly="System.Web.DynamicData, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

 

5) Enable the new ASP.NET Routing feature:

IIS 5/6/Casini

In the <httpModules> section add the following new module:

<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

IIS 7

In the <system.webServer>/<modules> section add the following:

<remove name="UrlRoutingModule" />

<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

In the <system.webServer>/<handlers> section add the following:

<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

 

At this point you need to register your Linq to SQL data modelin step #2 and optionally enable scaffolding by setting ScaffoldAllTables := true in the registratoin line. At this point if you copied the Default.aspx from the dummy Dynamic Data application you can execute it to view the scaffold. You can also enable Dynamic Data in existing web pages that use GridView, ListView, FormView and DetailsView by adding a DynamicDataManager to those pages and then registering the data control with the dynamic data manger:

 

<asp:DynamicDataManager id="DynamicDataManager1" runat="server">

<asp:GridView id="GridView1" runat="server">

...

DynamicDataManager1.Register(GridView1);

 

Inside of your GridView or DetailsView you can either use AutoGenerateColumns or you can use DynamicField controls in your column collections. If you are using ListView or FormView use DynamicControl to display values for each of your columns.

Posted by scothu | 8 Comments

Dynamic Data DbImage SampleUpdated

I posted a sample back in January on how to display images from databases or the file system using Dynamic Data. You can view that post HERE. I've just updated that sample to fix some bugs and add some new functionality. You can download the latest version of DbImage from this link: DOWNLOAD DBIMAGE.

Here is a list of the changes and updates I've made since the original post:

1) Fixed an issue that caused DbImage not to work when the primary column for the table is a GUID.

2) Added support for compound primary keys (primary key that is more then one column in the table).

3) Added support for Entity Framework (previous release would display images in Entity Framework but fail to update them).

4) The asp:FileUpload control does not work correctly inside of UpdatePanels with partial rendering turned on. By default the templates in Dynamic Data are enclosed in UpdatePanels with partial rendering turned on. This means that uploading of images will fail unless partial rendering is disabled. The new sample adds a helper method call in the Page_Init of the Insert, Edit and ListDetails page templates. This helper call looks to see if any of the displayed columns are DbImage columns and if so turns off partial rendering for the page.

DbImageAPI.ImageHelper.DisablePartialRenderingForUpload(this, DetailsDataSource.GetTable());

Posted by scothu | 17 Comments
Filed under: ,
More Posts Next page »
 
Page view tracker