StringLength(“Maximum Length”“Error Message”, “Error Resource”, “Error Resource Type”)The only issue is that when you set this attribute it sets the text box max length which means that it is impossible for the user to exceed the maximum you set so any error message will never be displayed!
However, this is the same behaviour that Dynamic Data does by default based on the table definition, so the attributes real use is either when you want to restrict the length of a string so that its shorter than the database allows, or if using Entity Framework and you create your own entity you can limit the length of data entered using the standard dynamic data functionality.
As per always to use simply decorate the property with the attribute