Monday 29 March 2010

Asp.Net Dynamic Data – RequiredAttribute

The RequiredAttribute overrides the model to allow you to specify a nullable field has to be completed.

Its constructor allows you to specify the error message you want to display instead of the standard error message:

Required(“Error Message”, “Error Resource”, “Error Resource Type”)

Just decorate the property with the attribute as per below:

[Required(ErrorMessage = "You must enter a phone number"))]]

public object Phone { get; set;}

And the user will then see:

2010-03-29_2146

Simple.

No comments:

Post a Comment