Question

I've read the related questions but I cannot find one that suits my problem(or i'm just stupid).

Basically i have a factory that renders a certain "template" and that template contains certain "entities". These entities can render themselves and have a void Render method that constructs the HTML and returns it to the template factory.

Now, for maintainability this is a nightmare. If the customer wants a space in between the html the dlls would need to be recompiled (Which is terrible!)

I need a way to move the logic + HTML out of the void Render method and into some kind of control, parse the control and return HTML at run time. So that the code can be relatively well maintained.

I'm using Asp.Net MVC and the template factory is a class library. Is there any way to accomplish this?

Thanks!

Was it helpful?

Solution

Sounds like what you want is a strongly-typed ViewUserControl for each "entity." This is basically how I've implemented widgets in a project I'm working on. Each widget has it's own widget model and a partial view (ViewUserControl) strongly-typed to that model. The widget uses the model's properties to render a view of that widget.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top