Last post Sep 15, 2014 04:01 PM by Alan L
Sep 09, 2014 12:55 PM|Alan L|LINK
VS2013, VB, working with MVC 5
In this Code Project article which uses C#
(link to article) the author shows a Data Annotation as below: (about halfway down the linked page in a yellow code section)
I thought the equivalent VB would be:
My naming is slightly different: The name of my error string is FirstNameRequired instead of the author's NameRequiredError. My resource file is "ErrorMessages.resx" where the author's is named "resources.resx". Unfortunately the author's resource file
is named the same as the keyword "Resources" that is in my project's Intellisense. Although these names are different, as I type each term in the line above, everything shows up just fine in Intellisense so I'm assuming my references are being setup correctly.
But Visual Studio complains about the assignment above saying:
Constant expression is required
I was successful using that same error message from the default resource file named "ErrorMessages.resx" with the following line:
In the Code Project article I've referenced, about a screen scroll above the line I showed at the top of this post, there is a Solutions Explorer screen shot with a Class library where the author's .resx files are being kept. I don't have that because the
Visual Studio web site instructs to create the .resx files in a folder called App_GlobalResource (link).
So my question is why can't I reference the elements of my resource file in a similar way to the Code Project article without the error message?
Sep 15, 2014 03:57 AM|adian_J|LINK
Please have a look at resource below.
Hope these links give you the way to fix the issue.
Sep 15, 2014 04:01 PM|Alan L|LINK
Thanks for those links, but they both refer to C#, and my question is trying to determine the VB equivalent.