Click here to Skip to main content
15,070,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a page (contactus.aspx) in my web site which is in VB.Net and that page has only static data. I want that all the static data is converted into the arabic language. For this I added an App_LocalResources folder in my web site and in that folder I added a Resource file named as ''. But it still shows static data on that page in English.

Please could you offer some guidance in how I might overcome this problem?
Do I need to add some code in contactus.aspx.vb file?
Updated 11-Apr-11 22:37pm
R. Giskard Reventlov 12-Apr-11 4:38am
What have you already tried?

You need to make sure that:

1. You're referencing the resources correctly in the markup of contactus.aspx
2. You're setting the CurrentUICulture correctly

Some Links that may help:[^][^]
make a folder Name "localization Test" in visiual studio 2008 or any

Step 1:
add a aspx page name Test1

the code behind

Partial Class localizatioin_test_page1

    Inherits BasePage

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Session("lang") = 1 Then
            Session("lang") = 2
            Session("lang") = 1
        End If

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Session("lang") = 1
        End If

    End Sub

End Class

the html

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="page1.aspx.vb" Inherits="localizatioin_test_page1" culture="auto" meta:resourcekey="PageResource1" uiculture="auto" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">

        <asp:Label ID="Label1" runat="server" Text="value1"
        <br />
        <asp:Label ID="Label3" runat="server" Text="value2"
        <br />
        <asp:Label ID="Label2" runat="server" Text="value3"
        <br />
        <asp:Button ID="Button1" runat="server" Text="Change Lang"
            meta:resourcekey="Button1Resource1" />


Step 2:

Note: with code behind and html the page is ready.
Note: in code behind we are using Inherits BasePage

make a class name BasePage and put the code given below and put the BasePage in App_Code folder.
Imports Microsoft.VisualBasic
Imports System.Data
Public Class BasePage
    Inherits Page
    Protected Overloads Overrides Sub InitializeCulture()
        Dim culture As String = String.Empty
        If Session("lang") = "1" Then
            culture = "ar-EG"
            culture = "en-US"
        End If

        If (String.IsNullOrEmpty(culture)) Then
            culture = "Auto"
            'Use this
            UICulture = culture
            culture = culture
        End If
        'OR This
        If (culture <> "Auto") Then
            Dim ci As New System.Globalization.CultureInfo(culture)
            System.Threading.Thread.CurrentThread.CurrentCulture = ci
            System.Threading.Thread.CurrentThread.CurrentUICulture = ci
        End If
    End Sub
End Class

Step 3: goto page test1 and tool-> generate local resources
it will create a folder named App_LocalResources and a local resource file named page1.aspx.resx
copy the page1.aspx.resx and paste in same folder and rename as

now you have two files
1. page1.aspx.resx

page1.aspx.resx is original one and translate in arabic

run the page it will work
ahsan.subiya 12-Apr-11 8:05am
sir did the same as you said.the page is runni ng without any error bt the output is only

when i click on the button nothing happend

please tell what your code is doing.
thanks and regard
subiya ahsan

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900