views:

192

answers:

3

I want to use the DataAnnotations.DisplayAttribute.Order property to arrange my fields when using the DisplayForModel and EditorForModel methods.

Related question:
Does the DataAnnotations.DisplayAttribute.Order property not work with ASP.NET MVC 2?

I think that I need to use the ASP.NET MVC 2 Futures. But I can't get it to work.

How do I install ASP.NET MVC 2 Futures?

Why are my fields still out of order?

+2  A: 

You should just need to download the futures DLL (Microsoft.Web.Mvc.dll), add a reference to it in Visual Studio, and reference the namespace Microsoft.Web.Mvc

Data Annotations are just attributes, so you may not see compiler errors if there is a problem. The attribute will just not work. You should obtain the source for futures and include it in your project, so that you can breakpoint the appropriate attribute servicing code and make sure it is firing.

Robert Harvey
I think Robert meant the Microsoft.Web.MVC.dll as that's the futures assembly
Nick DeVore
@Zack: Sorry about that. Fixed.
Robert Harvey
+1  A: 

You probably need to register the metadata provider in your global.asax.

DataAnnotations4ModelMetadataProvider.RegisterProvider();

And also, Microsoft.Web.Mvc.AspNet4.dll is the assembly. You can get it from here http://aspnet.codeplex.com/releases/view/41742

Matt Dotson
+2  A: 
  1. Download ASP.NET MVC 2 Futures from CodePlex.

  2. Save its files somewhere in the file system:

    C:\Program Files\Microsoft ASP.NET\ASP.NET MVC 2 Futures\

  3. In the project, right-click References and choose Add Reference

  4. Browse to and then select file Microsoft.Web.Mvc.AspNet4.dll

  5. Register the model metadata provider in Global.asax.cs:

    protected void Application_Start()
    {
        ...
        ModelMetadataProviders.Current = new DataAnnotations4ModelMetadataProvider();
        DataAnnotations4ModelValidatorProvider.RegisterProvider();
    }
    
Zack Peterson