Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi. I did override InitializeCulture in my base page. here is my code :

Public MustInherit Class BasePage

Inherits Page
Implements IBasePage

Protected Overrides Sub InitializeCulture()
    Dim selectedLanguage As String = "fa-IR"
    UICulture = "fa-IR"
    Culture = "fa-IR"
    Thread.CurrentThread.CurrentCulture = _
        CultureInfo.CreateSpecificCulture(selectedLanguage)
    Thread.CurrentThread.CurrentUICulture = New  _
        CultureInfo(selectedLanguage)

    MyBase.InitializeCulture()
End Sub


one of my pages :
Partial Class UI_Security_NewUser
Inherits Negso.Common.BasePage

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

   

End Sub

End Class

But the culture does not changed. when i write these code in main page it will change. but in base page not. what is the problem? do i have to call function?
Posted

Hi,

I tested the following code with the BasePage code you provided:

VB
Imports System.Threading
Partial Class TestCulture
    Inherits BasePage
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Write("Current UI Culture : " & Thread.CurrentThread.CurrentUICulture.Name)
        Response.Write("<br />")
        Response.Write("Current Culture : " & Thread.CurrentThread.CurrentCulture.Name)
    End Sub
End Class


And, found the following output, as desired:

SQL
Current UI Culture : fa-IR
Current Culture : fa-IR


And, I replaced the "Inherits BasePage" with "Inherits Page"

XML
Imports System.Threading
Partial Class TestCulture
    Inherits Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Write("Current UI Culture : " & Thread.CurrentThread.CurrentUICulture.Name)
        Response.Write("<br />")
        Response.Write("Current Culture : " & Thread.CurrentThread.CurrentCulture.Name)
    End Sub
End Class


And, following is the output (Default culture, in my machine):

SQL
Current UI Culture : en-US
Current Culture : en-US


So, it seems, your code is working :)

Am I missing something? Or, are you sure about the basepage
VB
Negso.Common.BasePage
that you are inheriting in your Page is the correct BasePage that overrides the InitializeCulture() method?
 
Share this answer
 
oops.... What a big..... i am so careless... i have to rebuild my basepage.... it is another dll. sorry all. solved.
 
Share this answer
 

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