ASP.NET MVC + Dynamic Data Sample
ASP.NET, C#, Learning notes, Visual Studio December 14th, 2007
ASP.NET MVC and Dynamic Data are both nice stuff, can they work together? sure! David just blog about it:
Will this work with MVC?
In this initial Preview, Dynamic Data is mostly targeting ’standard’ ASP.NET pages, but we are absolutely planning to support Dynamic Data for MVC. And the good news is that you can actually try this today! To do this:
- Download the MVC Toolkit from http://asp.net/downloads/3.5-extensions/
- This has a VS solution which contains a sample Blog project that uses Dynamic Data with MVC.
This was completely unadvertised, so most folks probably didn’t see it, but it’s in there for you to play with! Start by just running it, and then look through the source code, which is all part of the solution. Of course, it’s all very preliminary, and far from feature complete, but it should give you an idea of where we’re heading. If there is enough interest, I’ll try to make a screen cast that shows it.
The ASP.NET MVC Toolkit provides HTML rendering helpers and dynamic data support for MVC, it’s separated from the CTP install package.
This is how the blog sample works:
Controller, inherit from DynamicDataController, defined inside the toolkit.
namespace Blog.Controllers {
public class CommentController : DynamicDataController<Comment> { }
}
The DynamicDataController will render some aspx views default inside “view/shared”. In the example, the view post define its own view in “view/post/Show.aspx”, since ASP.NET MVC’s RenderView(”Show”) will fist look inside view/<controllerName>/<viewname> first, the customized version will be used over the shared one.
The default “Dynamic Data web” project created by template have very different structure than the MVC Dynamic Data demo project. I wish in the next release, tge MVCDynamicData can be included by default.
What I expecting is the feature that user can drag database table columns into a web form, and generate the CRUD scaffold with those web form, in that case, database centric web develop will be much easier. (though FoxPro, PowerBuild, Delphi, or maybe VB, have this kind of feature for many years) That’s something that I expected for a long time, can’t believe this kind of solution doesn’t exist before.
About
Leave a Comment