ContosoUniversity
ContosoUniversity copied to clipboard
FormBlocks
Hi Jimmy, I've been reading you articles about templates and like the way you did the FormBlock code. However, I can't seem to get a textarea to display. I've added [DataType(DataType.MultilineText)] to my model property but it seems to ignore it. Should I extend your example and create a specific "TextAreaBlock" or something else?
TDK1964,
I am not sure if this is the "correct" way to do it, but I added the following code to the DefaultAspNetMvcHtmlConventions.cs
file:
Editors.If(er =>
{
var attr = er.Accessor.GetAttribute<DataTypeAttribute>();
return attr != null && attr.DataType == DataType.MultilineText;
}).ModifyWith(m => m.CurrentTag.TagName("textarea").Attr("rows", "3"));