Re: HELP Pretty please :-)
- From: "Robert Dufour" <bdufour@xxxxxxxxxx>
- Date: Thu, 26 Apr 2007 20:00:40 -0400
I've read the article and been to her web site seing the globalization
samples and copied and studied the web one , but I still don't see why the
line
Request.Form.Item("Language1") always returns nothing when used in a web
site with master page but detects the control value OK when a master page
is not involved.
That seems to be the crux of the problem, the code does not find the control
Language1 on the web page, when its in a page that uses a master but it
finds it OK in a simple web page. Why and how to fix it?
Thanks
Bob
"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@xxxxxxxxxxxxxxxxxx> wrote in
message news:756BD0A2-6968-43DA-8EAA-5639FBAE0948@xxxxxxxxxxxxxxxx
Check where you have the resource files. It matters.
I would read Michele Bustamante's first article for more info on
meta:resourcekey versus attaching resources using other declarative means
of linking to local/global resources.
http://msdn2.microsoft.com/en-us/library/aa478974.aspx
This article is also great if you want to move to external resources or
database:
http://msdn2.microsoft.com/en-us/library/aa905797.aspx
Her blog (www.dasblonde.com) has some great globalization/localization
posts.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
*********************************************
Think outside the box!
*********************************************
"Robert Dufour" <bdufour@xxxxxxxxxx> wrote in message
news:uDaxwSDiHHA.872@xxxxxxxxxxxxxxxxxxxxxxx
I am trying to localize a very simple web site (english and french)
I have a master page and one content page for now.
On the master page I have placed a Localize control
On the content page I have placed a label and a dropdownlist. The label
says "Use this language" or "Utilisez cette laague"
The dropdownlist Contains values "en-US" text Englsih Us and "fr-CA" text
"French Canada)
I have resource files for the master page in english and french with a
key saying "welcome" value Welcome in english and Bienvenue in french
resource file. They are local resource files for the master.
The objective is to allow the user to switch languages by settting the
current threads UiCulture and Culture in code when the user selects
another language. When he -she changes language in the dropdown list ,
the content of the master file localize control should change and the
contents of the content page should change.
I've been f.. around with this one for over two days but I can't get it
working.
I have based my code on the code in the sample video on msdn for
localization but in this case just extending it to work with a master
page I've hit a brick wall :-(
Can someone PLEASE, prety please give a hand on this one.
This is the code I've come up with so far
1- the master page, just a standard masterpage with one localized control
on it.
<%@ Master Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Localize ID="LocWelc" runat="server" meta:resourcekey="Welcome"
Text="Welcome"></asp:Localize><br />
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
2- The content page - standard page with default culture and Uiculture
set tp fr-CA
<%@ Page Language="VB" MasterPageFile="~/Site.master"
AutoEventWireup="false" CodeFile="Default3.aspx.vb"
Inherits="Default3" Title="Untitled Page" Culture="fr-CA"
UICulture="fr-CA"%>
<%-- Add content controls here --%>
<asp:Content runat="server" ID="d3C"
ContentPlaceHolderID="ContentPlaceHolder1"
EnableViewState="true">
<asp:Label ID="Label1" runat="server" Text="<%$ Resources:Label1.Text
%>"></asp:Label>
<asp:DropDownList ID="Language1" runat="server" AutoPostBack="True"
Width="149px">
<asp:ListItem Value="fr-CA">Français (Canada)</asp:ListItem>
<asp:ListItem Value="fr-FR">Français (France)</asp:ListItem>
<asp:ListItem Value="en-CA">English (Canada)</asp:ListItem>
<asp:ListItem Value="en-US">English (US)</asp:ListItem>
</asp:DropDownList>
</asp:Content>
3- The code behind of the content page
Imports System.Threading
Imports System.Globalization
Partial Class Default3
Inherits System.Web.UI.Page
Protected Overrides Sub InitializeCulture()
If Request.Form.Item("Language1") IsNot Nothing Then
Dim Lang As String = Request.Form.Item("language1")
Thread.CurrentThread.CurrentCulture = _
CultureInfo.CreateSpecificCulture(Lang)
Thread.CurrentThread.CurrentUICulture = New _
CultureInfo(Lang)
End If
End Sub
End Class
All the controls on both master and content page have had their
expressions text property set to point to the appropriate key in the
resource file.
The main problem appears to be that no matter what, when I change the
selection in the drop down list the variable
Request.Form.Item("Language1") always returns nothing I can never obtain
the value of the dropdownlist selected item.
I can get it to detect the selected language if I detect it in the
selected index changed event of the language1 control but this event
fires well after the Initialize culture event, so If I use that I am
always using the previously selected item not the one that is currently
being selected.
The technique described above with the code in the code behind works OK
in a stand alone content page but it fails miserably when you make a
content page that uses a master page. I have not been able to find any
sample code on how to use this with master pages.
The second part of the question, sorry if its long, is how do you change
the value of the localize control on the master page when the user
selects another language in the content page?
I am realy desperate and would really appreciate any help anyone would be
kind enough to give
Thanks you in advance to all
Bob
.
- Follow-Ups:
- Re: HELP Pretty please :-)
- From: Göran Andersson
- Re: HELP Pretty please :-)
- References:
- HELP Pretty please :-)
- From: Robert Dufour
- Re: HELP Pretty please :-)
- From: Cowboy \(Gregory A. Beamer\)
- HELP Pretty please :-)
- Prev by Date: Re: IHttpHandler.IsReusable (how long is an instance pooled when IsReusable = true?)
- Next by Date: Re: Pre-approved Labor available with us
- Previous by thread: Re: HELP Pretty please :-)
- Next by thread: Re: HELP Pretty please :-)
- Index(es):
Relevant Pages
|