2

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.

Lundin
  • 195,001
  • 40
  • 254
  • 396
KristianMedK
  • 1,659
  • 6
  • 24
  • 52

1 Answers1

5

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.

Community
  • 1
  • 1
CodingIntrigue
  • 75,930
  • 30
  • 170
  • 176