I have a resource that a key will have a space, like
My key | Some string
In my aspx page I want to call
<%$ Resource:Resources, My Key %>
Is there some syntax that allows me to use “My Key” instead of “MyKey”?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. The key for a resource setting may not contain spaces. Resource files are compiled so that the keys become variable names. This would be the equivalent of saying:This just is not allowed.
I take it back. Having applied some tests, this can be done and basically as you have described it. Some things that I see off the top is that in a web site, the resources file can’t be in the
App_GlobalResourcesfolder it needs to be inApp_LocalResources. I named my resources file the same as my page name like:Default.aspx.resx. Resources in theApp_GlobalResourcesfolder are set at internal scope automatically.Inside it I had 2 keys and 2 values set:
To acess them from a control in the webpage I used a hyperlink control to test it:
Which output a link with the text
ThisValue. And also:Which output a link with the text ‘My Value’. I did notice that if I attempted to specify the “class” parameter by using
Resources: Default.aspx, My Keyit bombed. It was only successful using the resources within theApp_LocalResourcesfolder and only when specified to that file name.I’m sure this isn’t the only way to do this, but this method was successful in allowing a space in the key name for that page.