Welcome to MSDN Blogs Sign in | Join | Help

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 | 6 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 | 5 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 | 7 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 | 8 Comments

Dynamic Data is on .NET Rocks!

A few weeks ago I did an interview with Carl and Richard from .NET rocks on Dynamic Data. You can listen to it here: http://www.dotnetrocks.com/default.aspx?showNum=349.

Posted by scothu | 5 Comments

New Refresh of Dynamic Data Runtime and Tools is Posted

Tonight we posted a new release of the Dynamic Data Runtime and Tool on the Code Gallery website. You can grab the new release by clicking here: http://code.msdn.microsoft.com/dynamicdata/Release/ProjectReleases.aspx?ReleaseId=954. We have also updated the samples to work with the latest runtime, they are available here: http://code.msdn.microsoft.com/dynamicdata/Release/ProjectReleases.aspx?ReleaseId=850.

There are many changes and fixes in this new update. Here are the highlights:

Installation

The previous release could experience problems during installation on 64-bit computers and on computers that do not have the full .NET Framework SDK installed. The current release includes the required tools for installation, so it works on computers that have just the .NET Framework 3.5 installed. Installation on 64-bit computers should work properly now.

Upgrading

Various changes have been made to the field templates and .css files that are in the “DynamicData” folder. The best upgrade path (if practical) is to copy the new “DynamicData” folder into an existing project; the new folder contains all the latest field templates.

Documentation

The previous release was released with no documentation except the Readme file. This release contains a "Preliminary ASP.NET Documentation.chm" Windows Help file file that contains some documentation for ASP.NET Dynamic Data. This is ASP.NET 3.5 pre-release documentation and is not supported by Microsoft. Blank topics are included as placeholders and existing content is subject to change in future releases.

Dynamic Data Runtime

Dynamic Data now defaults to using separate pages for listing and editing data instead of using the combined List/Details style that was used in the earlier release. You can re-enable the previous method by changing the routes in the Global.asax file.

All metadata attributes now perform validation in the Web page. In the previous release, a metadata validation attribute caused validation to be performed only if the field template contained an ASP.NET server validation control that mapped to the attribute.

Dynamic Data now can use routing not only for the path, but for the query string as well. For example, instead of having the primary key passed as an explicit query string value (Products/Details.aspx?productid=1) , the key can instead be part of the URL (Products/Details/1). This change enables you to create cleaner routes, as shown in the following example:

RouteTable.Routes.Add(new DynamicDataRoute("MyCategoryDetail/{CategoryID}") {

Model = model,

Table = "Categories",

Action = "Details"

});

RouteTable.Routes.Add(new DynamicDataRoute("{CategoryID}/MyProductList") {

Model = model,

Table = "Products",

Action = "List"

});

In the first route definition, the primary key is passed as part of the path (for example, /app/MyCategoryDetail/5). In the second example, the foreign key is being passed as part of the URL (for example, /app/5/MyProductList). The foreign key does not have to be reversed, obviously; this example just shows what you can do with routing in Dynamic Data.

The DataTypeAttribute attribute has new values, such as EmailAddress and Html. When DataTypeAttribute is applied to columns with types of Date, Time, and Currency, Dynamic Data now applies default formatting of {0:d}, {0:t}, and {0:C} automatically, which provides a nicer display in display and edit modes. You can override this behavior by placing a DisplayFormatAttribute attribute on the column.

The fallback behavior of Dynamic Data for types that are not recognized has been changed. Instead of displaying an exception, a blank value is returned. This occurs when columns are displayed that Dynamic Data does not have a field template for.

The TextArea_Edit.ascx field template has been renamed to MultilineText_Edit.ascx. This change was made so that he template maps to the MultilineText data type that DataTypeAttribute supports. In addition, the <textarea> element that is rendered by the control has been made larger.

Tools and Dynamic Data Website Wizard

The Dynamic Data Website Wizard (Preview) template is now supported for Visual Basic.

The pages generated by the wizard have undergone the following changes:

· Pages use the included Site.master page by default. (Eventually the wizard will let you choose a custom master page or choose to use no master page.)

· ValidationSummary and DynamicValidator controls are generated, which enables automatic handling of validation exceptions.

· Improvements and changes have been made to the styles that are applied to the wizard-generated pages. These changes are defined in Site.css.

· An improved ListViewPager user control for paging in the ListView control has been added to the template.

· Several code generation improvements have been made. These includes rendering drop-down lists for foreign-key fields in edit and insert modes, confirmation dialog boxes for Delete links, addition of an EmptyDataTemplate template in the ListView control, and fixing the Show All Items (formerly Go Back) links for Details forms.

Posted by scothu | 5 Comments

Podcast with Scott Hanselman on Dynamic Data

I was able to sit down with Scott Hanselman last week after giving a Dynamic Data talk to the Microsoft MVP's and record a podcast about Dynamic Data. Here is a link to the podcast, enjoy: http://www.hanselminutes.com/default.aspx?showID=127

Posted by scothu | 1 Comments

Telerik has released some sample field template controls for Dynamic Data

One of the very cool extensibility points of Dynamic Data is our field template mechanism. In the existing data controls like GridView and DetailsView when the controls render a column they use some build in classes like BoundField, CheckBoxField, etc to display the column. These are not very extensible and once you decide you want to take over the rendering you need to turn the column into a templated column and manually manage the column yourself. With Dynamic Data what we have done is created a new concept called a Field Template which has a naming convention based on the data type. We provide the source code to these and they live in a directory "DynamicData\FieldTemplates". What this means is if you want to change the way a boolean column is rendered or edited you can go into that directory and modify Boolean.ascx and Boolean_Edit.ascx yourself. Whatever changes you make here will affect the way that booleans are shown and editing across your entire site. You can also add new FieldTemplates with custom names and in that case to make the control use them you can either mark you data model with a UIHint:

[MetadataType(typeof(ProductMetadata))]

public partial Product {

}

 

public class ProductMetadata {

  [UIHint("IntegerSlider")]

  public object UnitsOnOrder { get; set; }

}

 

or do it on page by page basis:

 

<Columns>

<DynamicField DataField="UnitsOnOrder" UIHint="IntegerSlider">

</Columns>

 

This should be really exciting for custom control vendors because they can now create FieldTemplate controls which can be dropped in the directory making our controls automatically use their fancier controls right out of the box. Telerik has released some early samples of some of their controls wrapped in FieldTemplates today which you can look at by jumping to this blog post: http://blogs.telerik.com/AtanasKorchev/Posts/08-04-16/RadControls_and_ASP_NET_Dynamic_Data_-_Part_Deux.aspx?ReturnURL=%2fblogs.aspx. We have other control vendors doing the same thing and I will blog about them when they are released.

Posted by scothu | 0 Comments

New Public Preview of Dynamic Data is Now Available

Today we released a new public release of Dynamic Data on the MSDN code gallery site. You can download the new version at: http://code.msdn.microsoft.com/dynamicdata. These releases are cutting edge releases and not as refined as a CTP but this is a great way for us to get much newer code than the December CTP into peoples hands. We need as much feedback as we can get on this new version so we can lock down Dynamic Data for RTM.

 

Also as part of this new public release is the new "Dynamic Data Website Wizard". This is a new wizard for building a Dynamic Data drive site from a wizard type experience. You can select a database, decide which items from the database need to be in the data model then customize the site on a page by page basis determine which operations the pages support including layout types. Then the tool generates the actual website using the features of Dynamic Data controls. You can read much more and see a screencast at: http://code.msdn.microsoft.com/dynamicdata/Wiki/View.aspx?title=Wizard&referringTitle=Home

 

We have also released some samples including an image library for Dynamic Data. You can see these samples at: http://code.msdn.microsoft.com/dynamicdata/Wiki/View.aspx?title=Samples%20Page&referringTitle=Home.

 

Please try out these new bits and give us feedback on the ASP.NET forums at: http://forums.asp.net/1145.aspx

Posted by scothu | 2 Comments

Sample for Displaying Images Updated + Screencast

We've recently started getting newer builds of Dynamic Data out to the private testers and soon to more public testers. As a result I've got an updated version of my image controls that I posted on my blog in January. As well I've recorded a screen cast that shows how to use the image controls in a project. Here is the link to the new DbImage project for display images from the database or file system in a Dynamic Data project: DOWNLOAD DBIMAGE.

 

Here is a link to a screencast on how to use the controls: VIEW SCREENCAST.

 

Basic steps for using this in a project:

 

1) Open the zip file and open the redist directory. Copy the DLL from the Bin directory to the Bin directory in your website.

2) In the Redist\FieldTemplates directory copy the files from that directory to the DynamicData\FieldTemplates directory in your website.

3) Open the web.config and add "<add path="ImageHandler.ashx" verb="*" type="DbImageAPI.ImageHandler" />" to the httpHandlers section of your web.config.

 

At this point you have enabled image support in your project. To get it to work you need to add a UIHint attribute to the column in your data model that contains the image. Here are the steps for doing this for the Category table in Northwind.

 

1) Create a partial class for the Category table to extend the Category table in the data model. Right click on the project and click "Add New Item". Select "Class". Type in "Category". Press Add.

2) Add "using System.ComponentModel.DataAnnotations" and "using DbImageAPI" to the using clause section.

3) Change the definition of the class to look like this:

[MetadataType(typeof(CategoryMetadata))]
public partial class Category
{
}

public class CategoryMetadata {
    [UIHint("DbImage")]
    public object Picture { get; set; }
}

What we have done is changed the Category class to be a partial class so it extends the class from the data model. Next we have created a class "CategoryMetadata" that is used to provide metadata for the Category class. The MetadataType attribute is what associates this class with the original Category class. Next we have created a Picture member which we can place metadata on (this is sort of a hack we do today because C# does not support adding attributes on existing members in partial classes, hopefully a future version of C# will address this). Then we apply the UIHint attribute which specifies which field template will be used to render this column.

 

At this point running the application should display the images.

 

The sample download contains both the redist directory that contains all the stuff for adding this support to an existing project. Plus a fully running sample that builds the library. Enjoy!

Posted by scothu | 10 Comments

Presenting At VSLive in San Francisco Next Week

I will be presenting Dynamic Data at VS Live in San Francisco next week on March 31, 2008. You can see full details of the show here: http://vslive.com/2008/sf/. My presentation is at 3pm on Monday. If you are at the show please stop by and see Dynamic Data in action. Bradley Millington from the Web Tools team will be doing a presentation on Visual Studio 2008 and .NET 3.5 as well. Plus there are sessions on MVC and Silverlight. Hope to see you there!

Posted by scothu | 0 Comments
More Posts Next page »
 
Page view tracker