KristianMedK
KristianMedK

Reputation: 1841

Embedded code (<%= %>) in button control

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

Answers (1)

CodingIntrigue
CodingIntrigue

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

Related Questions