Culture/Resource problem

T

Thor W Hammer

DESIGNER:

<asp:Button runat="server" ID="b1" Text="<%$ Resources:products,
PopularProducts %>" />

CODE BEHIND:

protected void Page_PreRender(object sender, EventArgs e)
{
Response.Write(Resources.Products.PopularProducts);
}

These two should both be linking to the same resource, but the problem is
that only the one in code behind writes the correct language. The first one
always gets the text from the default resource file and not the one with the
current/correct culture. I have set the current thread's cultures in the
base-page. Why isn't the two examples giving the same value?

Twh
 
B

Bruce Barker

timing. you are proably setting the culture in onload, but

<asp:Button runat="server" ID="b1" Text="<%$ Resources:products,
PopularProducts %>"

is processed prior to onload, while prerender is long after. change your
code to use binding or move the text assignment to the code behind.

-- bruce (sqlwork.com)
 
T

Thor W Hammer

Thank you, I changed it and set the culture in the InitCulture method and
now it works.

By the way, can you tell me how to read a local resource from code-behind ?

Twh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,265
Messages
2,571,071
Members
48,771
Latest member
ElysaD

Latest Threads

Top