Failed to assign resource key to asp.net label

I am new to development, as a startup, I study various videos and tutorials. Right now in the face of a strange problem

I have an asp.net label

<asp:Label ID="Label2" runat="server" Text="<%$ Resources:Label1TextKey %>" /> 

and I defined his key in

 App_GlobalResources >> Resource.resx >> Label1TextKey 

but when I build, he gives

 Error 1 The resource object with key 'Label1TextKey' was not found. C:\Documents and Settings\Maya\My Documents\Visual Studio 2008\WebSites\WebSite1\Default.aspx 14 

Can the body help me too?

+4
source share
2 answers

well, you are mistakenly using

correct declaration

 <%$ Resources:[filename prefix,]resource-key %> 

in your case Resource file name and resource key Label1TextKey

Source http://quickstarts.asp.net/QuickStartv20/aspnet/doc/localization/localization.aspx

+2
source

It should be:

 Text="<%$ Resources:Resource,Label1TextKey %>" 

The syntax is as follows:

 <%$ Resources:ClassName,KeyName,DefaultValue %> 

where ClassName is the name of the resource file, and KeyName is the key inside this file.

+5
source

Source: https://habr.com/ru/post/1332649/


All Articles