In the process of functional development project requires a lot of multi-language, especially foreign companies in the development of the system are generally good versions several languages, also need to implement multiple languages while our previous development projects
So we wrote a extended class Page class, so every page to achieve a multi-language inherit it. The class to achieve the following:
/// <summary>
/// Summary description for WebPageBase
/// </summary>
public class WebPageBase : System.Web.UI.Page
{
public WebPageBase()
{
}
protected override void InitializeCulture()
{
// set the initial language is Japanese
String lang = "JA-JP";
(! String.IsNullOrEmpty (Convert.ToString (the Request [ "Lang"]))) IF
{
lang = Convert.ToString (the Context.Session [ "lang "]);
lang lang =;
}
the else
{
lang = Convert.ToString (the Context.Session [" lang "]);
lang lang =;
}
// Culture property is used to help localize page content. It can be set to any valid culture ID.
// For example, EN-US culture ID page will be set to US English, while the fr culture ID page will be set to French.
// set the value may also Auto , to automatically detect the browser's preferred language and the language setting. can
// to the default values (e.g., Auto: EN-US ) defining automatic language detection.
UICulture = lang;
Culture = "";
base.InitializeCulture();
}
protected string Lang
{
get { return Convert.ToString(Context.Session["lang"]); }
set { Context.Session["lang"] = value; }
}
}
Code for this class is so simple, multi-language page you want to inherit it.
Reproduced in: https: //www.cnblogs.com/kevinGao/archive/2012/01/15/2323341.html