Polymorphic MVC Views

So, I make the registration page in ASP.NET MVC, and theres is a list of fields that change depending on a number of conditions (taken from the database).

What would be considered the best approach for displaying these fields in a view with no code changes every time the database is updated.

The current system that I think of is compiling a dictionary with the name "Name, DataType" and then iterating over the list and placing a new input type for each name (using the switch for the data type to get the correct editor). But this is similar to the old-fashioned and not fully taking advantage of the .NET MVC system (such as validation, default values, custom editors for specific content).

Is there any approach that I may not know in .NET to solve this problem?

+5
source share
1 answer

I had a very similar problem. Post here .

No, ASP.NET MVC has no understanding of polymorphism. At least I couldn't get it to work, doing tons and tons of experiments and asking this question several times differently in Stack Overflow.

@model, , , ( , , , , ).

, . , . DRY, , , ASP MVC.

, .

+6

All Articles