Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7192591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:58:19+00:00 2026-05-28T19:58:19+00:00

I somehow managed to make my company’s website in 9 languages, using Visual Studio

  • 0

I somehow managed to make my company’s website in 9 languages, using Visual Studio 2010 / VB / ASP.NET 4.0. I believe I’m using sessions. But you can tell for sure if you see the code provided below. I know this message is long, but I really need help.

It’s a multilingual site, and I managed to put flags on the homepage. When I click a flag, the page’s text changes to that language. When you click the French flag, it gets the information from the “FR” .resx resource file in my apps_GlobalResources folder. It stays on that language for the end-user’s entire session. Great! Well, not so great.

The URL, for instance, about.aspx, remains about.aspx. Granted, the text changes to French, but I’ve been told that it’s recommended to make it look like, if the client chooses French, for example, domain.com/about.aspx?lang=FR

But I have NO idea how to do this. If anybody can guide me clearly in the right direction, it’d be sincerely appreciated!!!

(For reference, if anybody is kind enough to delve into this issue, which may be a simple one, all of my files I’ve used in this are included below — and they’re kinda lengthy)

—-Homepage.master (how I’m calling the languages — just 2 samples)–

  <asp:LinkButton ID="LinkButton6" runat="server"
  CommandArgument="de" OnClick="RequestLanguageChange_Click"
  class="flagbutton">      
  <asp:Image ID="Image7" runat="server" ImageUrl="~/images/flagde.png"
  tooltip="View this website in Deutsch" title="View this website in Deutsch"/>
  <img class="map" src="images/flaghoverde.png" alt=""/>
  </asp:LinkButton>

  <asp:LinkButton ID="LinkButton5" runat="server"
  CommandArgument="fr" OnClick="RequestLanguageChange_Click"
  class="flagbutton">      
  <asp:Image ID="Image6" runat="server" ImageUrl="~/images/flagfr.png"
  tooltip="Voir ce site en français" title="Voir ce site en français"/>
  <img class="map" src="images/flaghoverfr.png" alt=""/>
  </asp:LinkButton>

—————code behind homepage.master.vb———————

     Partial Public Class Homepage
    Inherits System.Web.UI.MasterPage
    Protected Sub Page_Load(sender As Object, e As EventArgs)
    End Sub

     Protected Sub RequestLanguageChange_Click(sender As Object, e As EventArgs)
    Dim senderLink As LinkButton = TryCast(sender, LinkButton)

    'store requested language as new culture in the session
    Session(Udev.MasterPageWithLocalization.Classes.Global.SESSION_KEY_CULTURE) = 
    senderLink.CommandArgument

    'reload last requested page with new culture
    Server.Transfer(Request.Path)
   End Sub
   End Class

———————BasePage.vb in App_Code folder——————–

  Imports Microsoft.VisualBasic
  Imports System
  Imports System.Data
  Imports System.Configuration
  Imports System.Globalization
  Imports System.Threading
  Imports System.Web
  Imports System.Web.Security
  Imports System.Web.UI
  Imports System.Web.UI.WebControls
  Imports System.Web.UI.WebControls.WebParts
  Imports System.Web.UI.HtmlControls

  Namespace Udev.MasterPageWithLocalization.Classes
''' <summary>
''' Custom base page used for all web forms.
''' </summary>
Public Class BasePage
    Inherits Page
    Protected Overrides Sub InitializeCulture()
        'retrieve culture information from session
        Dim culture__1 As String =  
             Convert.ToString(Session([Global].SESSION_KEY_CULTURE))

        'check whether a culture is stored in the session
        If culture__1.Length > 0 Then
            Culture = culture__1
        End If

        'set culture to current thread
        Thread.CurrentThread.CurrentCulture =  
        CultureInfo.CreateSpecificCulture(culture__1)
        Thread.CurrentThread.CurrentUICulture = New CultureInfo(culture__1)

        'call base class
        MyBase.InitializeCulture()
    End Sub
   End Class
  End Namespace

———————-Culture.vb in App_Code folder——————–

  Imports Microsoft.VisualBasic
  Imports System
  Imports System.Data
  Imports System.Configuration
  Imports System.Web
  Imports System.Web.Security
  Imports System.Web.UI
  Imports System.Web.UI.WebControls
  Imports System.Web.UI.WebControls.WebParts
  Imports System.Web.UI.HtmlControls

  Namespace Udev.MasterPageWithLocalization.Classes
''' <summary>
''' This class provides ISO definitions for all cultures that are supported by this      
 application.
''' </summary>
Public Structure Culture
    'German - Switzerland definition
    Public Const DE As String = "de"
    'English - Great Britain definition
    Public Const EN As String = "en"
     End Structure
  End Namespace

——————Global.vb in App_Code folder————————

  Imports System
  Imports System.Data
  Imports System.Configuration
  Imports System.Web
  Imports System.Web.Security
  Imports System.Web.UI
  Imports System.Web.UI.WebControls
  Imports System.Web.UI.WebControls.WebParts
  Imports System.Web.UI.HtmlControls

  Namespace Udev.MasterPageWithLocalization.Classes
''' <summary>
''' Summary description for Global
''' </summary>
Public Structure [Global]
    Public Const SESSION_KEY_CULTURE As String = "culture"
    End Structure
  End Namespace
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:58:20+00:00Added an answer on May 28, 2026 at 7:58 pm

    Add something like this to your pages, at the top of OnInit (least preferred, as it means code-duplication). Ideally, this code would go to your base-page’s oninit (preferred), or your master-pages’s oninit (less preferred). Either way, it should work the way that you want.

    if(this.Request.Querystring["lang"] == null)
    {
        string path = this.Request.Url.AbsolutePath;
        string query = this.Request.Url.Query;
        if(query.length == 0)
            query = "?lang="; // concatenate language code here
        else
            query += "&lang="; // conc. lang. code here
        this.Response.Redirect(path + query, true);
        return;
    }
    

    This means: if the lang isn’t in query, refresh the page, but this time with lang in query.

    I hope I didn’t misunderstand the question.


    EDIT: VB version (oh, was it painful; I actually had to create a VB project for this):

    Protected Overrides Sub OnInit(e As System.EventArgs)
        MyBase.OnInit(e)
    
        If Me.Request.QueryString("lang").Length = 0 Then
            Dim path As String = Me.Request.Url.AbsolutePath
            Dim query As String = Me.Request.Url.Query
    
            If query.Length = 0 Then
                query = "?lang=" ' + add lang here
            Else
                query += "&lang=" ' add lang
            End If
    
            Me.Response.Redirect(path + query, True)
            Return
        End If
    
    End Sub
    

    So, it looks like you don’t have the OnOnit in your base class, but you can override it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was using std::hash_map<char*,T> and somehow managed to make it work but have now
Somehow I managed to make the date work, <td width=67><font size=3><b>*Date</b></td> <td width=3>:</td> <td
Somehow Visual Studio search has stopped working for me. Anytime I search Entire Solution
Somehow I had the impression that ASP.Net differentiates URLs based on the number of
I don't even remember how, but somehow I managed to make all of my
I need to make a simple asp.net MVC project, which contains a GridView. I
I've somehow managed to get an SVN repository into a bad state. I've moved
I have somehow managed to break my infopath form :( When I try to
Is it true that there's no way for Visual Studio 2008 to create a
I'm using Web Developer 2010. I just created a resource file lang.resx with different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.