in my applictaion,based on the selection of a field on the UI,I am loading a list of fields to be displayed from the database on the UI.Based on the selection,it is configured in the database each field is required or optional.After the UI is built,I do a post to the same view model(In the controller action).
What is the best way to do this?
I thought about doing this using reflection and add attributes on the properties based on the IsRequired flag against each field in the database,but i guess i have to eliminate the fields not needed from the UI.
So should i create a class as below as the best option or do i have something else?
Public Class ViewModelTicket
{
Public string EmailAddress{get;set}
Public bool IsRequired{get;set}
Public bool ShouldDisplay{get;set}
}
and throw a bunch of if else statements on the View ?
Thanks
Aucun commentaire:
Enregistrer un commentaire