Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 28th, 2007, 06:21 PM
Registered User
Join Date: Jul 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multi-language website: almost there

Hi all,

First a little introduction since this is my first post: I'm Wouter Bos (The Netherlands), but I use the alias Electricspace online. I'm learning ASP.NET for almost a year now and I'm finally getting somewhere. Didn't need to do a forum post before, but I'm stuck with a specific problem.

The problem: I'm trying to make a multi-langual website with .resx-files. Everything looks great, but I want a language switcher in order to give the user a chance to switch to another language. I can't make the switch permanent. The language switch is made after the RESX-variables are loaded and since the language switch isn't stored the next page load will still have the default language. There are a lot of examples out there for multi-langual sites, but I can't seem to fit it into what I want to have. Can anyone tell me what I am missing here?

the .asx file:
<%@ Control Language="C#" CodeFile="MenuLanguage.ascx.cs" Inherits="UserControlCode" meta:resourcekey="default" EnableViewState="false" %>

<asp:LinkButton runat="server" ID="Link_nl" Text="Nederlands" OnCommand="MenuLanguageButtonSwitch" CommandName="nl" />
<asp:LinkButton runat="server" ID="Link_en" Text="English" OnCommand="MenuLanguageButtonSwitch" CommandName="en" />

<asp:Label ID="LanguageFeedback" runat="server" Text="<%$ Resources: default, LanguageFeedback %>" />
the .ascx.cs file
using System;
using System.Collections;
using System.Configuration;
using System.Globalization;
using System.Threading;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControlCode : System.Web.UI.UserControl {

    void Page_Load(Object sender, EventArgs args)
        Response.Write("lan: "+ Thread.CurrentThread.CurrentCulture.ToString());

    protected void MenuLanguageButtonSwitch(object sender, CommandEventArgs e)
        Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(e.CommandName.ToString());
        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(e.CommandName.ToString());

        Response.Write(Thread.CurrentThread.CurrentUICulture.ToString()); // debug


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi Language Database nabeelalkaff BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 December 26th, 2007 02:41 AM
xslt multi language RoeZ XSLT 2 October 26th, 2007 06:50 AM
Multi language scenario edgarw BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 May 7th, 2007 08:08 AM
Multi-language Lofa ASP.NET 1.0 and 1.1 Basics 2 October 25th, 2005 04:10 AM
Multi-Language version Gjerstad BOOK: ASP.NET Website Programming Problem-Design-Solution 2 July 18th, 2003 05:02 AM

All times are GMT -4. The time now is 11:18 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.