Sunday 16 May 2010

Attribute Validation - String Length

Follows the same steps in the previous blog (Attribute Validation) however replace "Range" with "StringLength" for the Categories Description section.

The code should look like this:

using System.Web.DynamicData;
using System.ComponentModel.DataAnnotations;
///
///
Summary description for Categories
///
[MetadataType (typeof(CategoriesMetaData))]
public partial class Category
{
}
public class CategoriesMetaData
{
[Required]
[StringLength(100,ErrorMessage="Less than 100 characters")]
public object Description;
}

No comments:

Post a Comment