protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { // get all languages in the umbraco site var allLanguages = Language.GetAllAsList().ToList(); var currentContext = UmbracoContext.Current; // get current back office user var currentUser = currentContext.UmbracoUser; // make a guess at the default culture to show for this user var currentUmbracoLanguage = new Language(1); foreach (var language in allLanguages) { if (language.CultureAlias.Contains(currentUser.Language)) { currentUmbracoLanguage = language; } } // create a dropdown for the user to select which language they want to search ddlLanguage.DataSource = allLanguages.OrderBy(f => f.FriendlyName); ddlLanguage.DataTextField = "FriendlyName"; ddlLanguage.DataValueField = "id"; ddlLanguage.DataBind(); ddlLanguage.SelectedValue = currentUmbracoLanguage.id.ToString(); } }
public IEnumerable <Language> GetAllLanguages() { var allLangs = Language.GetAllAsList(); return(allLangs); }