Sure, why not,
Here's the code for the .aspx, named 16.3.2.aspx
<%@ Page Inherits="myCod eBehind_1633" Src="16.3.3.vb"
ResponseEncodin g="utf-8" %>
<html>
<head>
<title>Using Resource Files in ASP.NET</title>
</head>
<body style="FONT: x-small Verdana, Arial, sans-serif">
<form method="post" runat="server">
<b>The Current Culture is:</b>
<asp:Label id="CultureType " runat="server"> </asp:Label>
<hr />
<p>
<b>
<asp:Label id="Welcome" runat="server"> </asp:Label>
</b>
</p>
<p>
<b>
<asp:Label id="Choose" runat="server"> </asp:Label>
</b>
<asp:DropDownLi st id="EncodType" runat="server"
AutoPostBack="T rue">
<asp:ListItem Value="en-US" Text="English" />
<asp:ListItem Value="en-NZ" Text="English (New Zealand)" />
<asp:ListItem Value="fr-FR" Text="French" />
<asp:ListItem Value="de-DE" Text="German" />
<asp:ListItem Value="he-IL" Text="Hebrew" />
<asp:ListItem Value="ja-JP" Text="Japanese" />
<asp:ListItem Value="es-MX" Text="Spanish (Mexican)" />
<asp:ListItem Value="uk-UA" Text="Ukrainian (Ukraine)" />
</asp:DropDownLis t>
</p>
<asp:DataGrid id="myDataGrid " runat="server"
AutoGenerateCol umns="False" HeaderStyle-ForeColor="Whit e"
HeaderStyle-BackColor="Blac k" Font-Size="8pt" Font-Name="Verdana"
ShowFooter="fal se" BorderColor="bl ack" Width="740">
<Columns>
<asp:BoundColum n DataField="Firs tName" />
<asp:BoundColum n DataField="Last Name" />
<asp:BoundColum n DataField="Birt hDate"
DataFormatStrin g="{0:D}" />
<asp:BoundColum n DataField="Hire Date"
DataFormatStrin g="{0:D}" />
</Columns>
</asp:DataGrid>
</form>
</body>
</html>
and here's the code behind file 16.3.3.vb
Imports System
Imports System.Data
Imports System.Data.Sql Client
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.W ebControls
Imports System.Web.UI.H tmlControls
Imports System.Globaliz ation
Imports System.Threadin g
Imports System.Resource s
Imports System.IO
Public Class myCodeBehind_16 33 : Inherits Page
Public myDataGrid As DataGrid
Public EncodType As DropDownList
Public CultureType As Label
Public Choose As Label
Public Welcome As Label
Public rm As ResourceManager =
ResourceManager .CreateFileBase dResourceManage r("myResourceFi le",
Server.MapPath( "/resources") & Path.DirectoryS eparatorChar, Nothing)
Public Sub Page_Load(Sende r As Object, E As EventArgs)
Dim culture As CultureInfo
Dim myDataAdapter As SqlDataAdapter
Dim myDataSet As New DataSet
If Not Page.IsPostBack Then
culture = CultureInfo.Cur rentCulture
Else
culture = New CultureInfo(Enc odType.Selected Item.Value)
Thread.CurrentT hread.CurrentCu lture = culture
End If
CultureType.Tex t = culture.English Name
Welcome.Text = rm.GetString("G reeting", culture)
Choose.Text = rm.GetString("E ncMessage", culture)
myDataGrid.Colu mns(0).HeaderTe xt = rm.GetString("F irstName", culture)
myDataGrid.Colu mns(1).HeaderTe xt = rm.GetString("L astName", culture)
myDataGrid.Colu mns(2).HeaderTe xt = rm.GetString("B irthDate", culture)
myDataGrid.Colu mns(3).HeaderTe xt = rm.GetString("H ireDate", culture)
myDataAdapter = New SqlDataAdapter( "Select LastName, FirstName,
BirthDate, HireDate From Employees", _
"server=localho st;database=Nor thwind;uid=sa;p wd=ohlywohly;")
myDataAdapter.F ill(myDataSet, "Employees" )
myDataGrid.Data Source = myDataSet.Table s("Employees"). DefaultView
myDataGrid.Data Bind()
End Sub
End Class
and here's the code for the five resources files. you have to compile them
first before using them using
resgen
C:\Inetpub\wwwr oot\Sams\TipsTr icks\C16\resour ces\myResourceF ile.de-DE.txt
C:\Inetpub\wwwr oot\Sams\TipsTr icks\C16\resour ces\myResourceF ile.de-DE.resources
resgen
C:\Inetpub\wwwr oot\Sams\TipsTr icks\C16\resour ces\myResourceF ile.fr-FR.txt
C:\Inetpub\wwwr oot\Sams\TipsTr icks\C16\resour ces\myResourceF ile.fr-FR.resources
resgen
C:\Inetpub\wwwr oot\Sams\TipsTr icks\C16\resour ces\myResourceF ile.en-NZ.txt
C:\Inetpub\wwwr oot\Sams\TipsTr icks\C16\resour ces\myResourceF ile.en-NZ.resources
resgen
C:\Inetpub\wwwr oot\Sams\TipsTr icks\C16\resour ces\myResourceF ile.es-MX.txt
C:\Inetpub\wwwr oot\Sams\TipsTr icks\C16\resour ces\myResourceF ile.es-MX.resources
resgen C:\Inetpub\wwwr oot\Sams\TipsTr icks\C16\resour ces\myResourceF ile.txt
C:\Inetpub\wwwr oot\Sams\TipsTr icks\C16\resour ces\myResourceF ile.resources
first 'myResourceFile .de-DE.txt'
[strings]
Greeting = Willkommen!
FirstName = Vorname
LastName = Familienname
BirthDate = Geburtsdatum
HireDate = Miete-Datum
EncMessage = Wählen Sie Ihre Verschlüsselun g:
and then no two with the name 'myResourceFile .en-NZ.txt'
[strings]
Greeting = Good Day!
and number three 'myResourceFile .es-MX.txt'
[strings]
Greeting = Bienvenido!
FirstName = Nombre de pila
LastName = Apellido
BirthDate = Fecha de Nacimiento
HireDate = Fecha de Alquiler
EncMessage = Escoja su codificación:
number four: 'myResourceFile .fr-FR.txt'
[strings]
Greeting = Accueil!
FirstName = Prénom
LastName = Nom de famille
BirthDate = Date de Naissance
HireDate = Date de Location
EncMessage = Choisissez votre codage:
and at last number 5: 'myResourceFile .txt'
[strings]
;
; lines beginning with semi-colons are treated as comments
;
; Specify a locale-specific welcome message
Greeting = Welcome!
;
; Create locale-specific header text for our DataGrid
FirstName = First Name
LastName = Last Name
BirthDate = Birth Date
HireDate = Hire Date
;
; Create locale-specific text for our Label
EncMessage = Choose your encoding:
The .resources files should be saved to a /resources directory below the
root directory.
Kenneth P.
"Joyjit Mukherjee" wrote:
Hi,
can you post us the code ?
regards
Joyjit
"Kenneth P" <Ke******@discu ssions.microsof t.com> wrote in message
news:62******** *************** ***********@mic rosoft.com... Hi,
I have a very good book on asp.net Sams ASP.NET Tips, Tutorials and Code
ISBN 0-672-32143-2 and is trying to teach myself from examples from this
book Chapter 16.
Anyway I come quite close when trying to run one example but then I get
this message I don't understand:
"This .resources file shouldn't be used with this reader. Your resource
reader type: System.Resource s.ResourceReade r, mscorlib,
Version=1.0.241 1.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9"
What does it mean?
Seems my english isn't good enough.
TIA
Kenneth P