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..
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 %>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With