Reputation: 9611
I have a input tag like:
<input src="..." title="<%= SomeResource.Label1 %>" />
It is not rending the text, it is rendering the actual value in the title attribute:
<%= SomeResource.SoeLabelInMyResourceFile%>
I tried single quotes and no change, what am i doing wrong?
It is suppose to render the title attribute as:
title="some text value stored in the resource file"
So the issue is the server tags are not being rendered, rather it is thinking that is plain text I want to display for the value of the title attribute.
UPDATE
The text renders just fine if I do this:
<td>
<%= SomeResource.Label1 %>
<input src="..." title="" />
</td>
But if I put the tags inside the title attribute, I get the error.
Upvotes: 3
Views: 1240
Reputation: 15218
UPDATE
1 Create service folder App_GlobalResources (Project -> Add -> ASP.NET Folder)
2 Move resx-files to this folder
3 Get access to data:
In addition to programmatic access, ASP.NET 2.0 also introduces declarative syntax you can use to bind a named string to a property of a page or control. The syntax involves using the dollar sign ($) followed by the Resources namespace, the name of the resource file and the name of the string [see Resources and Localization in ASP.NET 2.0]
<asp:Literal runat="server" Text="<%$ Resources:Resource1, String1 %>" />
<input runat="server" type="text" value="<%$ Resources:Resource1, String1 %>" />
It works fine!
Try it:
<input src="..." title="<%$ Resources:SomeResource, Label1 %>" />
or
<input runat="server" src="..." title="<%$ Resources:SomeResource, Label1 %>" />
Upvotes: 1
Reputation: 1321
May be your input is marked as runat="server" ? If you'll remove runat="server" title="<%= SomeResource.Label1.Text %>" gonna be work as expected.
Upvotes: 0
Reputation: 7297
Try using GetLocalResourceObject()
<input src="..." title="<%= GetLocalResourceObject('SomeResource.Label1') %>" />
Upvotes: 0