Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't put a inline tag inside of a html input tag

Tags:

c#

asp.net

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.

like image 684
codecompleting Avatar asked Dec 14 '25 02:12

codecompleting


1 Answers

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 %>" />
like image 57
vladimir Avatar answered Dec 15 '25 16:12

vladimir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!