Using a Resource as an Attribute to a HTML Element in ASP.net
Posted
by Michael Stum
on Stack Overflow
See other posts from Stack Overflow
or by Michael Stum
Published on 2010-05-11T04:49:28Z
Indexed on
2010/05/11
4:54 UTC
Read the original article
Hit count: 255
I would like to have this piece of code in my .aspx file:
<input class="ms-ButtonHeightWidth" type="button" name="BtnOK" id="Button2"
value="Close"
onclick="javascript:HandleOKButtonClick()"
accesskey="<%$Resources:wss,okbutton_accesskey%>" />
Unfortunately, ASP.net doesn't seem to like that:
An error occurred during the processing of /_layouts/MyPage/Info.aspx.
Literal expressions like '<%$Resources:wss,okbutton_accesskey%>' are not allowed.
Use <asp:Literal runat="server" Text="<%$Resources:wss,okbutton_accesskey%>" />
instead
That doesn't work in this situation as that would mean nesting the Literal between the quotes of the accesskey attribute, which causes a "The tag contains duplicate 'ID' attributes" error.
Is there a way to use a string from a resource without having to change the input to an asp:Button? I guess there has to be a way using <%=
, but I don't know how I would address the resource itself?
© Stack Overflow or respective owner