Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
public class CustomModelMetadataProvider : DataAnnotationsModelMetadataProvider
{
protected override ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName)
{
var attributeList = attributes.ToList();
var modelMetadata = base.CreateMetadata(attributeList, containerType, modelAccessor, modelType, propertyName);
ProvideTextAreaForBigText(modelMetadata, propertyName);
return modelMetadata;
}
private void ProvideTextAreaForBigText(ModelMetadata modelMetadata, string propertyName)
{
if (propertyName != null && propertyName.EndsWith("_BigText") && string.IsNullOrEmpty(modelMetadata.TemplateHint))
modelMetadata.TemplateHint = "BigText";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment