troubleshooting Question

Change Globalisation resource using session variable ?

Avatar of swgdesign
swgdesignFlag for United Kingdom of Great Britain and Northern Ireland asked on
46 Comments1 Solution548 ViewsLast Modified:
I am currently developing an application that can be accessed via numerous domains name and in numerous languages (EN, DE, ES, FR, IT etc), so am using Globalisation for langaueg variations. The thing is due to branding and company names I need to use 1 base resource file for each domain name e.g.


and so on.

In the code below you can see I have set the resource to use Domain1.resx but if the users enter the site via etc I need to use the resource Domain2.resx

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If InStr(Request.Url.AbsoluteUri, "domain1") Then
            Session("GlobStrings") = "Domain1"
        ElseIf InStr(Request.Url.AbsoluteUri, "domain2") Then
            Session("GlobStrings") = "Domain2"
        End If
    End Sub

    Protected Overrides Sub InitializeCulture()
        If Request.Form("DropDownList1") IsNot Nothing Then
            Dim selectedLanguage As String = Request.Form("DropDownList1")
            UICulture = Request.Form("DropDownList1")
            Culture = Request.Form("DropDownList1")
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectedLanguage)
            Thread.CurrentThread.CurrentUICulture = New CultureInfo(selectedLanguage)
        End If
    End Sub

<asp:Label ID="Label1" runat="server" Text='<%$ Resources: Domain1, Home_Text1 %>'></asp:Label><br />
        <br />
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true">
            <asp:ListItem Value="en-GB">English</asp:ListItem>
            <asp:ListItem Value="de-DE">Deutsch</asp:ListItem>
            <asp:ListItem Value="es-ES">Espanol</asp:ListItem>

Is there a way to use the value of Session("GlobStrings") to get the correct resource strings?


Can I use some sort of REPLACE on the string being returned by the resources call?

<asp:Label ID="Label1" runat="server" Text='<%$ Resources: Session("GlobStrings"), Home_Text1 %>'>

The above does not work!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 46 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 46 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros