views:

312

answers:

3

I have an input button on an ASP.NET form, but I want the text displayed to come from a server side resource file.

The following syntax fails, and I can't enclose it in a literal because the input tag cannot contain any other tags:

 <input id="btnX" type="button" disabled="disabled" value='<%$Resources:res,Button.Text%>' />

Any possible solutions?

Thanks :)

+2  A: 

What about <%= function %> ?

apocalypse9
I've tried it, and by the look of things, it gets confused if there is a quote or equals sign in the resource object. Could work if we're careful though - thanks
Fiona Holder
As I recall intellisense doesn't like it much
apocalypse9
I just tested<input id="btnX" type="button" disabled="disabled" value="<%= Generated String%>" />It appears to work on my Test Server
apocalypse9
+1  A: 

I would think apocalypse's answer should work:

<%= GetLocalResourceObject("Button.Text") %>

or

<%= GetGlobalResourceObject("res", "Button.Text") %>
John
+1  A: 

It will work if you add runat="server" to the input tag.

vit
adding runat would alter his generated client id for the control; I'm guessing that's trying to be avoided
John