/// BasePage for the common funtionality in all
/// the web pages of the site.
public class BasePage: Page
/// Default constructor
// TODO: Add constructor logic here
/// The name of the culture selection dropdown list in the common header. We need this name
/// as we want to know the clintID of the language dropdown and we can't use ClientID or any other
/// control property as the control (dropdown) itself is not initialized yet. So we use the "nested"
/// dropdown name through which we will get the dropdown's value from the Request.Form collection.
public const string LanguageDropDownID = "ctl00$cphHeader$Header1$ddlLanguage";
/// The name of the PostBack event target field in a posted form. You can use this to see which
/// control triggered a PostBack: Request.Form[PostBackEventTarget] .
public const string PostBackEventTarget = "__EVENTTARGET";
/// Overriding the InitializeCulture method to set the user selected
/// option in the current thread. Note that this method is called much
/// earlier in the Page lifecycle and we don't have access to any controls
/// in this stage, so have to use Form collection.
protected override void InitializeCulture()
///Check if PostBack occured. Cannot use IsPostBack in this method
///as this property is not set yet.
if (Request[PostBackEventTarget] != null)
///Get the id of the control which triggered the PB
///Then we need to match this ID with the DropDown's ID
///to check if the dropdown was clicked and not some other control.
string controlID = Request[PostBackEventTarget];
string selectedValue = Request.Form[Request[PostBackEventTarget]].ToString();
case "0": SetCulture("hi-IN", "hi-IN");
case "1": SetCulture("en-US", "en-US");
case "2": SetCulture("en-GB", "en-GB");
case "3": SetCulture("fr-FR", "fr-FR");
/// Sets the current UICulture and CurrentCulture based on
/// the arguments
/// <param name="name"></param>
/// <param name="locale"></param>
protected void SetCulture(string name, string locale)
Thread.CurrentThread.CurrentUICulture = new CultureInfo(name);
Thread.CurrentThread.CurrentCulture = new CultureInfo(locale);
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Microsoft bets on Windows XP disaster