Search code examples
c#asp.net-mvc-3razorresource-file

C# problem with dot in resource file


I'm having a little problem with a dot (.) in a resource file. In my global.resx file I have the value:

Key: DSNLBuiltNo
Value: DS.NLM + Built no

When I display this in my Razor file with a @Html.Label(Global.DSNLBuiltNo) I only see NLM + Built no in my page (and the underlying HTML.) Anyone knows what is going on here?


Solution

  • It's because of the way the Label method works. By only including one string you're basically saying that the label is for that particular id. Since you didn't provide the actual label text it assumes that you're referencing an actual property somewhere and only uses the property name itself and not it's fully qualified namespace. To get the output you're expecting (if a label is the proper output) then you want to use:

    @Html.Label(Global.DSNLBuiltNo, Global.DSNLBuiltNo)
    

    or if you don't really need a label since it's not referencing an actual id anywhere

    @Global.DSNLBuiltNo