Reputation: 11480
I've recently started learning ASP.NET Model View Controller (MVC)
. It is very unique in the approach it takes for sites, I'm noticing the potential with dynamics
. Which will greatly improve maintenance.
But I can see how excessive use of dynamics
could be bad, especially if you deviate from the strongly typed model
. So my question is this...
I'm creating a layout, but I'd like the layout to be fluid
. I want the design to be changeable very easy without impacting my logic. I know you can create Master Pages
and Master Content Pages
which can hold a bulk of the layout for ease. Except that will still have limitations for my use.
Is there a way to change these Master Pages
and Master Content Pages
into true dynamic entities? Essentially a designer
could use a What you see is what you get field I create which allows the entire site to be modified?
My original thought was to store to create a dynamic layout
where each View
referenced a database; whatever those variables were would create the layout. But I'm not sure that is the best approach?
Any suggestions or thoughts for the best approach?
Please I'm not looking to start a debate, but if people could point me into a direction where I can research that method of implementation would be greatly helpful. That way I can find the best solution that will fit this projects need for a dynamic layout
.
Update:
To give background on this project, my company has several subsidiaries. Those subsidiaries will be utilizing the application but would like it tailored for there specific company. To avoid excessive design layouts I'd like to abstract
that portion.
That way my logic
will not be impacted, but the software be module enough to meet all our subsidiaries design needs without me having to customize every single one of them or risk a designer affecting the logic
.
Thank you for your assistance.
Update:
To help clarify, the goal is to allow the User Interface
to be decoupled from the application. In a normal Windows Application
I would utilize Inversion Of Control
to help segregate the interface and structure from the initial logic.
This decoupled approach is helpful, the goal is to decouple the interface in this case Razor Syntax
which would design create the structure. If you had a site:
<html>
<div id="Page-Container">
<div id="Header" />
<div id="Content" />
<div id="Footer" />
</div>
</html>
That structure would be static, but in my case I'd like it to be dynamic
. That way my logic can be abstracted through the structure but the designer can manipulate and change the page layout
however he'd like.
Upvotes: 4
Views: 1582
Reputation: 11178
This sounds like you are looking for some kind of CMS. There are already a bunch of CMS build for ASP.NET MVC, however you may build your own that will fulfill all your needs by storing views in DB. In this case this article might point you in the right direction.
Upvotes: 1
Reputation: 25409
Not sure if I'm understanding your requirements exactly..... but perhaps the following premise would be of interest?
@model CompanyName.LayoutModel
<html>
<body>
@foreach(string view in Model.Views)
{
@Html.Partial(view);
}
</body>
</html>
This is going to be dependent on how whatever UI framework you using works though. The idea being that you present to Razor an object that just contains a collection of views which Razor then renders partially. In order.
Instead of using ASP.NET MVC for the initial serving you might want to examine sites like http://www.google.com/ig, they use ajax to read custom layouts for the users (if you edit your settings in the home page you can completely customise the layout and what kind of news you get on the home page) and then fill those layouts with data from further ajax calls.
To me this sounds more flexible, each of those AJAX calls can be to ASP.NET MVC methods (which return the output of razor pages) and the javascript can just insert the HTML straight into the DOM. This also gives you greater flexibility when calling methods that might take longer to execute or rely on 3rd party communication as it allows you to render "loading" animations and report errors more easily.
Upvotes: 1
Reputation: 51
In razor you can easily do that.
You must have a model for your layout template and bind it in your razor layout.
Each part of layout can be in a @if
razor block which checks fields of model and dynamically
creates each part.
Upvotes: 0