Wednesday, March 4, 2009

Lap Around ASP.NET Dynamic Data 4.0 Preview

I was just going through my Last Dynamic Data article, and while surfing I came across ASP.NET Dynamic Data 4.0 Preview 1 & 2 (I am going to call it as Dynamic Data Future simply). I was exploring that throughout, so I though it will be good to share with you all if you are unaware of this.

Basically, ASP.NET Dynamic Data 4.0 requires to have Visual Studio 2008 and .NET Framework 3.5 SP to be installed first. I downloaded the bits from Codeplex and there you will find a big note like :

NOTE: These previews contains features that may not be in the next version of the framework. These previews are not production quality and should be used at your own risk.

So right now don’t plan this for your production bits unless you are confident about it. Even I am just still evaluating this one and now note from me : "No harm in Evaluating it, Its too Good !!”

There are few new attributes and Field Templates given, Dynamic Data 4.0 Preview also talks about BusinessLogicDataSource Control (In Common man’s term : Something which sync your UI and BL), It is now also go hand in hand with ASP.NET MVC, Beside Image handler the thing I like most is now we can add Search Capability to Dynamic Data and will be able to tweak it as we like it the way it should be.

Right now I am exploring Image Capabilities in Dynamic Data and sharing the same with you. Below screens are from walkthrough which I have downloaded from Codeplex and I will use same bits to explain you various features.

To enable Dynamic Data Grid with Images you have following newly introduce “Field Templates” :

  • DbImage.ascx
  • Edit_ DbImage.ascx
  • FileImage.ascx

To make Image mechanism smooth, you then need to add HTTP handler in your Web.Config File like this :

<add verb="*" path="ImageHandler.htm" type="Microsoft.Web.DynamicData.ImageHandler"/>

Rest of the steps like adding LINQ-to-SQL data model, drag table which you want to display etc steps are still same like in old one. (Sample bits gives you “Northwind” Database and you have “Categories” table which capable of storing images), Also whatever we do modifications in Global.asax are as it was in old.

To map Image field in database, job is now done by ImageAttributes which you need to add manually, which you will get from namespaces Microsoft.Web.DynamicData and System.ComponentModel.DataAnnotations ,well attributes seems to be powerful since they do allow you to set size of images too. But you need a partial class to map Categories Table which you can do by adding class file and declaring partial class in it like this :

public partial class CategoryMetadata{}
You can see now first entry page also slightly modified, previously we use to see List of Tables which we include in data model, now for Preview it has been modified slightly like this :
Once you click on link under “Display database Image columns” you will get output like below :
If you go ahead and check I done some editing of one field (Check lotus image in above grid, on which I experimented), you add new image or delete particular one like this :
A File Uploader makes job easy to add new image from your local physical storage and once you upload image you will promptly see changes in Grid (This image which you can see are actually Cached) and after updating you can see output like this : (lotus image is now replaced by Sunset image)
Well, That was all about Displaying Images in Dynamic Data,Surely in my future articles I will discuss all these in depth.
What is the Future of Dynamic Data ?? : 

Where you can find more about ASP.NET Dynamic Data 4.0 Preview 1 & 2 ?? :

Preview 1 :

Preview 2 :

Lost in Jungle? Confused ? Looking for something which will be step-by-step?? :

Hope you find this information useful, so don’t wait, download bits from Codeplex and start exploring them with me !


No comments: