Monday, March 30, 2009

ASP.NET - Dynamic Data - Read Only Column

This is a simple way to configure columns as Read Only when using Dynamic Data

Make two copies of the Text.ascx field template and name one ReadOnly.ascx and the other ReadOnly_Edit.ascx then annotate the field in your metadata partial class as follows

[UIHint("ReadOnly")]
public object UpdateDate;


This works fine as the UIHint uses the ReadOnly field template to display the column in display mode and the ReadOnly_edit template when in in edit mode. Both simply display the column using the aps:Literal control

Thursday, March 26, 2009

Dynamic Data Partial ClassGenerator

If you have ever done any .NET remoting in the past you would would have come across
Ingo Rammer part of the ThinkTecture Team. Ingo really knows his stuff and is a great speaker.

Anyway Ingo has created a small project which generates your metadata partial classes from your EF/L2S generated model. link

Its pretty handy. Give it a go

Thursday, March 19, 2009

Dynamic Data Templates in VS 2008

The Dynamic Data templates option in VS 2008 can be a bit confusing so here is an overview.

The “Dynamic Data Entities Web Site” template create an empty Entity Framework project and you use Add -> New -> ADO.NET Entity Data Model to add your data model to the project. The Dynamic Data routing is configured in the global.asax file.

If you want to control how Dynamic Data creates the UI and validates data input then add a new class using the System.ComponentModel.DataAnnotations name space. Example below

[MetadataType(typeof(Account_Metadata))]
public partial class Account
{
}

public partial class Account_Metadata
{

[ScaffoldColumn(false)]
public object UpdateDate { get; set; }

[StringLength(30)]
[Required(ErrorMessage = "Account name is required.")]
public object Description { get; set; }

The “Dynamic Data Web Site Wizard” template creates a Linq to Sql based project and the wizard guides you through the creation of the dd web site. As part of this you will get an option to create specific input forms for each entity.

It automatically creates a class named file YourModelDataContext.partial.cs which contains all the MetaData classes.

The routing info is in the class DynamicData.cs

Tuesday, March 10, 2009

Win an Xbox Elite or TechEd Plus subscription

If you attend the Microsoft community tech day this Thursday in Cork you will be in with the chance to win an Xbox Elite or one of two TechEd Plus subscription. The talks should be pretty good and will cover the following

Windows 7 & Windows Server 2008 R2 working Great Together and WS 2008 R2 Virtualisation
SharePoint - The Implementation Journey..from WSS to MOSS
Unified Communications - Using it Today and Preparing for the Future

Register on the Microsoft site below register