To allow the client to manually select their own language, I received instructions to install the following in my " basepage ". I just have regular .aspx pages and 5 master pages. I have a Visual Studio 2010 / vb / net 4.0 website. I just created my own class in Visual Studio and put the BasePage.vb in my app_code folder . Am I doing the right thing?
Public Class BasePage
Inherits Page
Private Const m_DefaultCulture As String = "en-GB"
Protected Overrides Sub InitializeCulture()
'retrieve culture information from session
Dim culture__1 As String = Convert.ToString(Session("MyCulture"))
'check whether a culture is stored in the session
If Not String.IsNullOrEmpty(culture__1) Then
Culture = culture__1
Else
Culture = m_DefaultCulture
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
Just create a class called BasePage and derive all your pages from that Page instead of classic ASP.NET Page.
Your BasePage would derive from classic ASP.NET Page.
Read Using a Custom Base Class for your ASP.NET Pages' Code-Behind Classes
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.