Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ErrorMessageResourceName property
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
MVC
Title:
ErrorMessageResourceName property
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01612177
Message ID:
01612177
Views:
632
UPDATE. Sorted that out now, it should have been ErrorMessageResourceName property and not ErrorMessage.

Hi everybody,

All of the sudden I started to get the following error:
Both ErrorMessageResourceType and ErrorMessageResourceName need to be set on this attribute.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Both ErrorMessageResourceType and ErrorMessageResourceName need to be set on this attribute.

Source Error: 


Line 52:                             <div class="controls">
Line 53:                                 <div class="col-lg-9">
Line 54:                                     @Html.PasswordFor(m => m.NewPassword, new { @class = "form-control", placeholder = Labels.newPassword, autocomplete = "off" })
Line 55:                                     @Html.ValidationMessageFor(m => m.NewPassword, null, new { @class = "help-inline" })
Line 56:                                 </div>

Source File: c:\_Siriusware\Main\SysManager\SysManager.Web\Views\ChangePassword\Index.cshtml    Line: 54 

Stack Trace: 


[InvalidOperationException: Both ErrorMessageResourceType and ErrorMessageResourceName need to be set on this attribute.]
In the model it's defined as
 [Required]
        [RegularExpression(SysManagerConstants.PASSWORD_REGULAR_EXPRESSION, ErrorMessage = "passwordInvalid", ErrorMessageResourceType = typeof(Messages),
            ErrorMessageResourceName =null)]
          
        [DataType(DataType.Password)]
        [Display(Name = "newPassword", ResourceType = typeof(Labels))]
        public string NewPassword { get; set; }
So I just added the ErrorMessageResourceName attribute to the RegularExpression but I don't know what should I set it to. I found this question

http://stackoverflow.com/questions/2347650/how-to-use-dataannotations-errormessageresourcename-with-custom-resource-solutio

but I am not sure I understand what Daren meant in that sample. .NET documentation as usual doesn't provide any examples of usage.

So, I am a bit lost of what should I use here as my name of the resource.
If it's not broken, fix it until it is.


My Blog
Reply
Map
View

Click here to load this message in the networking platform