ModelMetadata: ShowForEdit property not appearing to work.
Posted
by Dan
on Stack Overflow
See other posts from Stack Overflow
or by Dan
Published on 2010-06-02T09:13:41Z
Indexed on
2010/06/10
12:33 UTC
Read the original article
Hit count: 452
Iv wrote an MetaDataProvider like the one below and am using it in conjunction with Editor templates. The DisplayName is working correctly, but for some reason the ShowForEdit value it not having any effect. Any ideas?
public class MyModelMetadataProvider : DataAnnotationsModelMetadataProvider
{
protected override ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType,
Func<object> modelAccessor, Type modelType, string propertyName)
{
var metadata = base.CreateMetadata(attributes, containerType, modelAccessor, modelType, propertyName); I
metadata.DisplayName = "test";
metadata.ShowForEdit = false;
metadata.ShowForDisplay = false;
metadata.HideSurroundingHtml = true;
return metadata;
}
}
© Stack Overflow or respective owner