Problem with resources in ASP.net
I am creating one application in which I a开发者_StackOverflow社区m using resource files to keep strings. In my application I am keeping pages in separate folders like all the registration pages are in Register folder. I created on Resources folder in this folder to have all the resource files related to registration module. But, when I am trying to access resource strings
<asp:Label Text="<%$Resources: RegisterAsUser, userName%>" runat="server" />
It is giving error that userName key is not found. I am not able to figure out the error here.
Can anyone tell what is wrong here?
Thanks, Ashwani
You are using explicit expressions.
<asp:Label Text="<%$Resources: RegisterAsUser, userName%>" runat="server" />
whereas the other option is implicit expressions
<asp:Label ID="label1" runat="server" meta:resourcekey="userName" ></asp:Label>
For the explicit expressions as I understand it, the purpose of it is to used a shared location, so that resources from many aspx files can access the values from one resource file. For this to work, your resx file RegisterAsUser must be beneath the App_GlobalResources directory.
With implicit, the value is looked from in a resx file with the same name as the aspx file with the correct localization value of course.
精彩评论