viewmodel - ASP.NET MVC 2: Use [Data Annotations] to reference methods that could feed DDL lists? -


Generally accepted method of passing all data in one view is in the context of your domain model and both A data model should have additional data for things like drop down lists (DDLs).

However, partial visualization (visual templates) also receives a part of the main model, the original is not able to reach the root of the model sent. So, if your DDL lists are not stable, how do you get data for partial ideas?

Is there a way to use [data annotation] to use a method that can return the potential values ​​of a field, then in partial view DDL Use the? Where will this method exist in the repository?

The link or the C # code example will be very useful.

There is no creation in the data annotation attribute that you can ask.

You can create your own attribute, in which a reference of one type and the name of a static method, which you can open from your partial view through reflection.

Where will you keep such a method, depending on what you are doing, even though I still think it would be better to collect all the inputs in your controller. You can always set additional items in the data collection And can pass them in their partial view.


Comments