Re: HELP Pretty please :-)

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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&#231;ais (Canada)</asp:ListItem>

<asp:ListItem Value="fr-FR">Fran&#231;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















.



Relevant Pages

  • Re: HELP Pretty please :-)
    ... I have a master page and one content page for now. ... 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. ... 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. ... The main problem appears to be that no matter what, when I change the selection in the drop down list the variable Request.Form.Itemalways returns nothing I can never obtain the value of the dropdownlist selected item. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HELP Pretty please :-)
    ... When a control is inside a container like the Content control, it's id is changed to ensure that it's unique. ... Request.Form.Itemalways returns nothing when used in a web site with master page but detects the control value OK when a master page is not involved. ... 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. ... 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. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Visual Basic to be discontinued in 2008??
    ... LANGUAGE WE ALL LOVE ... Master Programmer wrote: ... The dataReader offers a fast read only blah blah - fucking crippleware ... I've been writing intranet sites for years using clientside vbscript. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Visual Basic to be discontinued in 2008??
    ... LANGUAGE WE ALL LOVE ... Master Programmer wrote: ... The dataReader offers a fast read only blah blah - fucking crippleware ... If Microsoft is going to COMPETE then why don't we hear about AVAX? ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Future of Java
    ... Jack of all trades master of none ... ... It's never wasted to learn more than one language. ... But when it comes to competition, on the java arena you'd always have to compete with people dedicated to the java platform, and on the C# arena you'd always have to compete with people dedicated to C#. ... And part of any adequate education in CS is getting familiar with a broad selection of programming languages. ...
    (comp.lang.java.programmer)