I have an mvc razor page which contains a form with fields created dynamically from the database ie the field name, type (textbox etc) are set in the db table as well as StringLength
Is there some way in my model to set the StringLength on the field to be a value from one of the other properties?
The questions are built up using an editor template for the QuestionModel, these are the relevant fields in the QuestionModel;
public string QuestionTypeName { get; set; } --> ie this is like TextBox, TextArea etc and is used to create the write EditorTemplate
[RequiredIf("Required", true)]
[StringLength(<<this is where I want to use the property FieldLength>>)]
public string Answer { get; set; }
[DisplayName("Question name")]
public string Question { get; set; }
public bool Required { get; set; }
public Int32 FieldLength { get; set; }