How do I install ASP.NET MVC 2 Futures?

感情迁移 提交于 2019-12-24 23:02:37

问题


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?


回答1:


  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();
    }
    



回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/2998865/how-do-i-install-asp-net-mvc-2-futures

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!