views:

402

answers:

2

Hello all

I am currently investigating MVC for a new project we are starting. So far I like it, but I'm wondering about something.

The actual views that we will be displaying will not be known at design time, we will be specifying in a config file somewhere how to build these views. Is this pattern supported by MVC or do we need to know at design time exactly what data we will be viewing?

If not, can someone give me some pointers on what I should be looking at as most of the info I have assumes that you have a model/view that is defined during your design.

Regards,

Alex..

+3  A: 

You can have your views weakly-typed... Your initial page directive on the view will look like:

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

... and then you can refer to data from your Controllers like this:

<%= ViewData["MyData"] %>

Is there some common interface that you are intending to pass to your view? If so, you can benefit from a using the generic ViewPage<> :

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<IamTheInterface>" %>

Then, you can use your interface to refer to your Model:

<%= Model.MyProperty %>
Jeff Fritz
Hi Jeff,This looks like good stuff thanks...Yes, each view will have exactly the same interface, basically just a grid with CRUD facilities.
Alex DeLarge
+1  A: 

There is cool post in LosTechies.com about building an "autoform" with fields autogenerated from the Model properties. Take a look, it might be what you are looking for.

Ariel Popovsky
Ariel, this looks very useful. Thanks a lot!
Alex DeLarge