User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 375,170 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,182 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 1052 | Replies: 0
Reply
Join Date: Oct 2006
Location: Beijing
Posts: 30
Reputation: VanPetrol is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
VanPetrol VanPetrol is offline Offline
Light Poster

"Back" mess up Language Selection Code

  #1  
Mar 19th, 2007
My site allow you to switch between 3 langauges.
At the time I created it, I still went with iFrames, and due to the size of the site now, very hard to go back and change everything.
All works fine, until the user start using that darn "BACK" and "FORWARD" buttoms. It seems the parent page, and the child pages respond different to the clicking of these buttons.
So, if the user changed his language, and then click "BACK", the "main" page will show in one language, and the child page in another.
I made 4 simple html pages with a javascript that control the iframe's source to demonstrate you my problem. Unzip demo.rar and run parent.html. [NO....CANNOT ATTACH HERE.....SEE SAMPLE CODE AT BOTTOM] Switch the language, and then use back....see?
Of course, in my asp.net pages it goes a bit deeper. Clicking the language buttons set this:
System.Web.HttpContext.Current.Response.Cookies["lang"].Value  = lang;
System.Web.HttpContext.Current.Response.Cookies["lang"].Expires = DateTime.Now .AddDays(360);
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang);
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
and I check the language in each page's (each of the about 20 child pages) load event.
But, once again, showing a page by clicking the back button, does not fire the load event at all...postback or de not. So it seems I got now way forcing the child page to check the parent's language when the Back and Next buttons are used.
ps: Noticed in firefox, clicking back and next does nothing. Better check in IE, will you?
 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=windows-1250">
  <title></title>
  <script type="text/javascript">
  function ChangeLang(lang)
  {
    topbox  = document.getElementById("body");
  topbox.src = lang + ".html";     
  
  if (lang=="en")
      document.getElementById("main").innerHTML  = "The parent and child should show in <b>ENGLISH</b>";
  else if (lang=="ja")
      document.getElementById("main").innerHTML  = "The parent and child should show in <b>JAPANESE</b>";
    else if (lang=="zh")
      document.getElementById("main").innerHTML  = "The parent and child should show in <b>CHINESE</b>";
  }
  </script>
  </head>
  <body>
  <table width="800">
    <tr>
      <td align="left" id="main">The parent and child should show in <b>ENGLISH</b></td>
      <td align="right">
        <a href="#" onclick="ChangeLang('en');">English</a>
        <a href="#" onclick="ChangeLang('ja');">Japanese</a>
        <a href="#" onclick="ChangeLang('zh');">Chinese</a>
      </td>
    <tr>
    <tr>
      <td colspan=2>
        <iframe src="en.html" name="body" id="body" width="800" >        
        </iframe></td>
    </tr>
  </table>
  </body>
</html>
If you want to use CSS to design Web sites you can't do it in a half-baked way. You are in or you're not in. - Charles Wyke-Smith
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 11:52 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC