Culture/Resource problem

  • Thread starter Thread starter Thor W Hammer
  • Start date Start date
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
 
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)
 
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

Back
Top