protected override void OnLoad(EventArgs e)
        {
            if (!IsPostBack)
            {
                TemplateFileSelectorControl.LoadTemplateFiles();

                TxtName.Text  = emailTemplate.Name;
                TxtAlias.Text = emailTemplate.Alias;
                ChkShouldClientReceiveEmail.Checked = emailTemplate.SendEmailToCustomer;

                EmailTemplateSettings defaultSettings = emailTemplate.Settings.SingleOrDefault(s => s.LanguageId == null);
                if (defaultSettings != null)
                {
                    TxtSubject.Text       = defaultSettings.Subject;
                    TxtSenderName.Text    = defaultSettings.SenderName;
                    TxtSenderAddress.Text = defaultSettings.SenderAddress;
                    TxtToAddresses.Text   = string.Join(";", defaultSettings.ToAddresses);
                    TxtCCAddresses.Text   = string.Join(";", defaultSettings.CcAddresses);
                    TxtBCCAddresses.Text  = string.Join(";", defaultSettings.BccAddresses);

                    TemplateFileSelectorControl.Items.TrySelectByValue(defaultSettings.TemplateFile);
                }

                foreach (Language language in umbracoLanguages)
                {
                    TemplateFileSelector templateFileSelectorControl = CurrentTabView.FindControl <TemplateFileSelector>("TemplateFileSelectorControl" + language.id);
                    templateFileSelectorControl.LoadTemplateFiles();

                    EmailTemplateSettings emailTemplateSettings = emailTemplate.Settings.SingleOrDefault(s => s.LanguageId == language.id);
                    if (emailTemplateSettings != null)
                    {
                        TextBox txtSubject       = CurrentTabView.FindControl <TextBox>("TxtSubject" + language.id);
                        TextBox txtSenderName    = CurrentTabView.FindControl <TextBox>("TxtSenderName" + language.id);
                        TextBox txtSenderAddress = CurrentTabView.FindControl <TextBox>("TxtSenderAddress" + language.id);
                        TextBox txtToAddresses   = CurrentTabView.FindControl <TextBox>("TxtToAddresses" + language.id);
                        TextBox txtCCAddresses   = CurrentTabView.FindControl <TextBox>("TxtCCAddresses" + language.id);
                        TextBox txtBCCAddresses  = CurrentTabView.FindControl <TextBox>("TxtBCCAddresses" + language.id);

                        txtSubject.Text       = emailTemplateSettings.Subject;
                        txtSenderName.Text    = emailTemplateSettings.SenderName;
                        txtSenderAddress.Text = emailTemplateSettings.SenderAddress;
                        txtToAddresses.Text   = string.Join(";", emailTemplateSettings.ToAddresses);
                        txtCCAddresses.Text   = string.Join(";", emailTemplateSettings.CcAddresses);
                        txtBCCAddresses.Text  = string.Join(";", emailTemplateSettings.BccAddresses);

                        foreach (ListItem item in templateFileSelectorControl.Items)
                        {
                            item.Selected = item.Value == emailTemplateSettings.TemplateFile;
                            if (item.Selected)
                            {
                                break;
                            }
                        }
                    }
                }
            }

            base.OnLoad(e);
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!IsPostBack)
            {
                TemplateFileSelectorControl.LoadTemplateFiles();
                TemplateFileSelectionListControl.LoadTemplateFiles();

                TxtName.Text            = store.Name;
                DrpCountries.DataSource = CountryService.Instance.GetAll(store.Id);
                DrpCountries.DataBind();
                DrpCountries.SelectedValue = store.GeneralSettings.DefaultCountryId.ToString();

                DrpVatGroups.DataSource = VatGroupService.Instance.GetAll(store.Id);
                DrpVatGroups.DataBind();
                DrpVatGroups.SelectedValue = store.GeneralSettings.DefaultVatGroupId.ToString();

                DrpOrderStatuses.DataSource = OrderStatusService.Instance.GetAll(store.Id);
                DrpOrderStatuses.DataBind();
                DrpOrderStatuses.SelectedValue = store.GeneralSettings.DefaultOrderStatusId.ToString();

                DrpConfirmationEmail.DataSource = EmailTemplateService.Instance.GetAll(store.Id);
                DrpConfirmationEmail.DataBind();
                DrpConfirmationEmail.Items.TrySelectByValue(store.GeneralSettings.ConfirmationEmailTemplateId);

                DrpPaymentInconsistencyEmail.DataSource = EmailTemplateService.Instance.GetAll(store.Id);
                DrpPaymentInconsistencyEmail.DataBind();
                DrpPaymentInconsistencyEmail.Items.TrySelectByValue(store.GeneralSettings.PaymentInconsistencyEmailTemplateId);

                ChkPricesIsSpecifiedWithVat.Checked = store.GeneralSettings.PricesIsSpecifiedWithVat;

                ChkPersistOrderId.Checked = store.GeneralSettings.CookieTimeout != null;
                if (store.GeneralSettings.CookieTimeout != null)
                {
                    TxtOrderPersistanceTimeout.Text = store.GeneralSettings.CookieTimeout.Value.TotalMinutes.ToString("0");
                }

                TxtCartNumberPrefix.Text  = store.OrderSettings.CartNumberPrefix;
                TxtOrderNumberPrefix.Text = store.OrderSettings.OrderNumberPrefix;

                TxtProductPropertyAliases.Text           = string.Join(",", store.ProductSettings.ProductPropertyAliases);
                TxtProductUniquenessPropertyAliases.Text = string.Join(",", store.ProductSettings.ProductUniquenessPropertyAliases);

                IEnumerable <Store> stores             = StoreService.Instance.GetAll().ToList();
                IEnumerable <Store> stockSharingStores = stores.Where(s => s.ProductSettings.StockSharingStoreId == store.Id).ToList();
                PPnlStockSharingStore.Visible        = stores.Count() > 1;
                DrpStockSharingStore.Visible         = !stockSharingStores.Any();
                LblStockSharingStoreAssigned.Visible = !DrpStockSharingStore.Visible;

                if (!stockSharingStores.Any())
                {
                    foreach (Store store1 in stores)
                    {
                        if (store1.Id != store.Id)
                        {
                            bool hasAccessToStore = currentLoggedInUserPermissions != null && currentLoggedInUserPermissions.HasPermission(StoreSpecificPermissionType.AccessStore, store1.Id);

                            if (hasAccessToStore || store1.Id == store.ProductSettings.StockSharingStoreId)
                            {
                                DrpStockSharingStore.Items.Add(new ListItem((!hasAccessToStore ? "* " : "") + store1.Name, store1.Id.ToString(CultureInfo.InvariantCulture)));
                            }
                        }
                    }
                    DrpStockSharingStore.Items.TrySelectByValue(store.ProductSettings.StockSharingStoreId);
                }
                else
                {
                    LblStockSharingStoreAssigned.Text = string.Join(", ", stockSharingStores.Select(s => s.Name));
                }

                TxtGiftCardLength.Text    = store.GiftCardSettings.Length.ToString(CultureInfo.InvariantCulture);
                TxtGiftCardDaysValid.Text = store.GiftCardSettings.DaysValid.ToString(CultureInfo.InvariantCulture);
                TxtGiftCardPrefix.Text    = store.GiftCardSettings.Prefix;
                TxtGiftCardSuffix.Text    = store.GiftCardSettings.Suffix;

                TemplateFileSelectorControl.Items.TrySelectByValue(store.UISettings.EditOrderUiFile);
                TemplateFileSelectionListControl.Items.Cast <ListItem>().ToList().ForEach(i => i.Selected = store.UISettings.AllowedFilesForClientRendering.Contains(i.Value));
            }
        }