views:

38

answers:

1

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?

+2  A: 

I think that the correct syntax is <%= Resources.wss.okbutton_accesskey %>.

In any case, all the resources, once compiled are accessible through Resources.[ResourceFileName].[Key]

Elph