Reputation: 1841
I'm working on a project where I'm using the <%= getString("key")%>
to dynamically get the appropriate text.
this works great when i use it in simple p tags, but i can't find a way to do this with controls like Button/Label etc.
Is there any way, other than calling
Mybutton.Text = getstring("key");
to dynamically add the text?
The idea is that getString retrieves af language code, and depending on that code gets a string in the appropiate language.
I've been looking around, but all i come across is using the embedded code tags directly in the aspx pages, which wont cut it for buttontext.
Upvotes: 2
Views: 710
Reputation: 78555
If you can use DataBinding instead of the <%=
operator, you can use:
<asp:Button ID="MyButton" Text='<%# getstring("key") %>' />
This is a good explanation of why <%=
won't work in this context.
Upvotes: 5