Hi Juan and Dave and Everybody else,
Using <%= worked fine.
I do set culture in Web.Config.
However in my page I have a button to change language (change culture).
It is working the following way:
1. Sets default culture in web.config as "en-US" and Session("culture")
as that value.
2. Detects in Global.asax in Session_start if a cookie exist in client.
3. If exists changes threat culture and also Session("culture")
Then I use <%= Session("culture") %> to change URL's, database fields
and other items in my HTML page.
I have some questions about my approach:
1. Should I use threat culture in <%= ... %>?
2. Should I set threat culture in Page_Load in all pages or setting it
only in Session_Start is enough? Well, at least until the language
button is not pressed which runs a function.
3. Is there a way to change the application culture itself? Is it
better?
These are the questions I came up when building this.
I would appreciate some feedback on this.
Thank You,
Miguel
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:no***********@nowhere.com:
In fact, you can probably skip the session object altogether.
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Globalization" %>
<img src='images/<%=CultureInfo.CurrentCulture.Name%>/myImage.jpg' />
If you are setting the culture in the globalization section of web.config,
that should work even better than setting a session("culture") variable.
Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:Oy**************@tk2msftngp13.phx.gbl...
re:
However the image doesn't show up.
Try importing the globalization namespace:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Globalization" %>
and setting Session("culture") to CultureInfo.CurrentCulture.Name :
<%Session("culture") = CultureInfo.CurrentCulture.Name%>
Then, you can retrieve the image name with :
<img src='images/<%=Session("culture")%>/myImage.jpg' />
Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:uK**************@tk2msftngp13.phx.gbl...
Hello,
I have this image in my HTML code:
<img src="images/en-US/myImage.jpg" />
I want to change the URL using the value of a Session variable.
<img src="images/ Session("culture") Value /myImage.jpg" />
This is what I did:
<img src='images/<%# Session("culture") %>/myImage.jpg' />
I change the " to ' because when I was using " I got an error.
I also did this to test my Session Value:
OO<% Response.Write(Session("culture")) %>OO
I got "OOen-USOO" which was what I was expecting.
However the image doesn't show up.
Can someone help me?
I don't know what else to do.
Thank You,
Miguel