Could the UIHint attribute accept a property of the current class ?

Posted by user252160 on Stack Overflow See other posts from Stack Overflow or by user252160
Published on 2010-04-11T15:58:35Z Indexed on 2010/04/11 16:03 UTC
Read the original article Hit count: 400

Filed under:
|
|

I found the follwing code in MSDN . How can I change this "UnitsInStock" with a value that my Product class has. For instance, Product has a FieldType property which has a string property called Name. I'd like to use that FieldType.Name property instead of hardcoding with a string. However, I cannot specify "this", or the current instance as an argument of the UIHint attribute . Please, help

using System; using System.Web.DynamicData; using System.ComponentModel.DataAnnotations;

[MetadataType(typeof(ProductMetadata))] public partial class Product {

}

public partial class ProductMetadata { [UIHint("UnitsInStock")] [Range(100, 10000, ErrorMessage = "Units in stock should be between {1} and {2}.")] public object UnitsInStock;

}

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about attributes