Esempio n. 1
0
    private static void AddValueCell(Panel row, string valueText)
    {
        var valueCell = new Panel
        {
            CssClass = "editing-form-value-cell"
        };

        row.Controls.Add(valueCell);

        // A block wrap because of block content
        var valueControl = new Panel
        {
            CssClass = "form-control-text"
        };

        // Content may contain block HTML tags
        var localizedContent = new LocalizedLiteral
        {
            Text = valueText
        };

        valueControl.Controls.Add(localizedContent);

        valueCell.Controls.Add(valueControl);
    }
Esempio n. 2
0
        private void QuoteListRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case ListItemType.Header:
                if (!IsQuote)
                {
                    LocalizedLiteral LocalizedLiteral2 = (LocalizedLiteral)e.Item.FindControl("LocalizedLiteral2");
                    LocalizedLiteral2.Text = "Ordtxt5";
                }
                break;

            case ListItemType.Item:
            case ListItemType.AlternatingItem:
                Literal    QuoteID          = (Literal)e.Item.FindControl("QuoteID");
                Literal    QuoteDate        = (Literal)e.Item.FindControl("QuoteDate");
                Literal    QuoteNumber      = (Literal)e.Item.FindControl("QuoteNumber");
                Literal    QuoteDescription = (Literal)e.Item.FindControl("QuoteDescription");
                Literal    QuoteCustomer    = (Literal)e.Item.FindControl("QuoteCustomer");
                Literal    QuoteOwner       = (Literal)e.Item.FindControl("QuoteOwner");
                Literal    QuoteTotal       = (Literal)e.Item.FindControl("QuoteTotal");
                LinkButton OpenQuote        = (LinkButton)e.Item.FindControl("OpenQuote");

                if (IsQuote)
                {
                    QuoteDate.Text = UC.LTZ.ToUniversalTime(Convert.ToDateTime(DataBinder.Eval((DataRowView)e.Item.DataItem, "expirationdate").ToString())).ToShortDateString();
                }
                else
                {
                    QuoteDate.Text = UC.LTZ.ToUniversalTime(Convert.ToDateTime(DataBinder.Eval((DataRowView)e.Item.DataItem, "QuoteDate").ToString())).ToShortDateString();
                }

                QuoteNumber.Text      = DataBinder.Eval((DataRowView)e.Item.DataItem, "Number").ToString();
                QuoteDescription.Text = DataBinder.Eval((DataRowView)e.Item.DataItem, "Subject").ToString();
                QuoteID.Text          = DataBinder.Eval((DataRowView)e.Item.DataItem, "ID").ToString();
                switch (Convert.ToByte(DataBinder.Eval((DataRowView)e.Item.DataItem, "CrossType")))
                {
                case 0:
                    QuoteCustomer.Text = DatabaseConnection.SqlScalar("SELECT COMPANYNAME FROM BASE_COMPANIES WHERE ID=" + DataBinder.Eval((DataRowView)e.Item.DataItem, "CrossID").ToString());
                    break;

                case 1:
                    QuoteCustomer.Text = DatabaseConnection.SqlScalar("SELECT ISNULL(NAME,'')+' '+ISNULL(SURNAME,'') FROM BASE_CONTACTS WHERE ID=" + DataBinder.Eval((DataRowView)e.Item.DataItem, "CrossID").ToString());
                    break;

                case 2:
                    QuoteCustomer.Text = DatabaseConnection.SqlScalar("SELECT ISNULL(NAME,'')+' '+ISNULL(SURNAME,'')+' '+ISNULL(COMPANYNAME,'') FROM CRM_LEADS WHERE ID=" + DataBinder.Eval((DataRowView)e.Item.DataItem, "CrossID").ToString());
                    break;
                }

                QuoteOwner.Text = DatabaseConnection.SqlScalar("SELECT ISNULL(NAME,'')+' '+ISNULL(SURNAME,'') FROM ACCOUNT WHERE UID=" + DataBinder.Eval((DataRowView)e.Item.DataItem, "OwnerID").ToString());

                QuoteTotal.Text = ((decimal)DataBinder.Eval((DataRowView)e.Item.DataItem, "GrandTotal")).ToString("N2");
                OpenQuote.Text  = "<img src=/i/lookup.gif border=0>";

                break;
            }
        }
        private void grdModules_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.EditItem)
            {
                LinkButton lnkUpdateButton = (LinkButton)e.Item.Cells[7].Controls[0];
                if (lnkUpdateButton != null)
                {
                    lnkUpdateButton.Text = ResourceManager.GetString("grid_lnkUpdateButton");
                }

                LinkButton lnkCancelButton = (LinkButton)e.Item.Cells[7].Controls[2];
                if (lnkCancelButton != null)
                {
                    lnkCancelButton.Text = ResourceManager.GetString("cmnCancel");
                }
            }


            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                LinkButton lnkModifyButton = (LinkButton)e.Item.Cells[7].Controls[0];
                if (lnkModifyButton != null)
                {
                    lnkModifyButton.Text = ResourceManager.GetString("grid_lnkModifyButton");
                }


                //-- Logic to hide the word months if lession frequency is 0 or empty.
                Label            lblLessonFrequency = (Label)e.Item.Cells[2].Controls[1];
                LocalizedLiteral lblLessonMonths    = (LocalizedLiteral)e.Item.Cells[2].Controls[3];
                if (lblLessonFrequency.Text == string.Empty || lblLessonFrequency.Text == "0")
                {
                    lblLessonFrequency.Visible = false;
                    lblLessonMonths.Visible    = false;
                }

                //-- Logic to hide the word months if quiz frequency is 0 or empty.
                Label            lblQuizFrequency = (Label)e.Item.Cells[3].Controls[1];
                LocalizedLiteral lblQuizMonths    = (LocalizedLiteral)e.Item.Cells[3].Controls[3];
                if (lblQuizFrequency.Text == string.Empty || lblQuizFrequency.Text == "0")
                {
                    lblQuizFrequency.Visible = false;
                    lblQuizMonths.Visible    = false;
                }
            }
        }
Esempio n. 4
0
    /// <summary>
    /// Logging in handler.
    /// </summary>
    private void loginElem_LoggingIn(object sender, LoginCancelEventArgs e)
    {
        // Ban IP addresses which are blocked for login
        if (!BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.Login))
        {
            e.Cancel = true;

            LocalizedLiteral failureLit = loginElem.FindControl("FailureText") as LocalizedLiteral;
            if (failureLit != null)
            {
                failureLit.Visible = true;
                failureLit.Text    = GetString("banip.ipisbannedlogin");
            }
        }

        loginElem.RememberMeSet = PersistentLogin;
    }
Esempio n. 5
0
    /// <summary>
    /// Ligging in handler.
    /// </summary>
    void Login1_LoggingIn(object sender, LoginCancelEventArgs e)
    {
        // Ban IP addresses which are blocked for login
        if (!BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.Login))
        {
            e.Cancel = true;

            LocalizedLiteral failureLit = Login1.FindControl("FailureText") as LocalizedLiteral;
            if (failureLit != null)
            {
                failureLit.Visible = true;
                failureLit.Text    = GetString("banip.ipisbannedlogin");
            }
        }

        if (((CheckBox)Login1.FindControl("chkRememberMe")).Checked)
        {
            Login1.RememberMeSet = true;
        }
        else
        {
            Login1.RememberMeSet = false;
        }
    }
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        if (SettingsCategoryInfo == null)
        {
            plcContent.Append(GetString("settings.keys.nocategoryselected"));
            StopProcessing = true;
            return;
        }

        ScriptHelper.RegisterTooltip(Page);
        ScriptHelper.RegisterBootstrapTooltip(Page, ".info-icon > i");

        // Loop through all the groups in the category
        int groupCount = 0;
        bool hasOnlyGlobalKeys = true;
        var groups = GetGroups(SettingsCategoryInfo);

        foreach (var group in groups)
        {
            // Get keys
            var keys = GetKeys(group.CategoryID).ToArray();

            // Skip empty group
            if (!keys.Any())
            {
                continue;
            }

            groupCount++;

            // Add category panel for the group
            var pnlGroup = GetCategoryPanel(group, groupCount);
            plcContent.Append(pnlGroup);

            // Loop through all the keys in the group
            int keyCount = 0;
            foreach (var keyInfo in keys)
            {
                // Increase key number for unique control identification
                keyCount++;

                // Update flag when non-global-only key exists
                if (!keyInfo.KeyIsGlobal)
                {
                    hasOnlyGlobalKeys = false;
                }

                // Create key item
                var keyItem = new SettingsKeyItem
                {
                    ParentCategoryPanel = pnlGroup,
                    KeyName = keyInfo.KeyName,
                    KeyType = keyInfo.KeyType,
                    ValidationRegexPattern = keyInfo.KeyValidation,
                    CategoryName = group.CategoryName,
                    ExplanationText = ResHelper.LocalizeString(keyInfo.KeyExplanationText)
                };

                Panel pnlRow = new Panel
                {
                    CssClass = "form-group"
                };
                pnlGroup.Controls.Add(pnlRow);

                // Add label cell to the beginning of the row
                var pnlLabelCell = new Panel
                {
                    CssClass = "editing-form-label-cell"
                };
                pnlRow.Controls.AddAt(0, pnlLabelCell);

                // Continue with the value cell
                pnlRow.Controls.Add(new LiteralControl(@"<div class=""editing-form-value-cell"">"));

                // Create placeholder for the editing control that may end up in an update panel
                var pnlValueCell = new Panel
                {
                    CssClass = "settings-group-inline keep-white-space-fixed"
                };
                var pnlValue = new Panel
                {
                    CssClass = "editing-form-control-nested-control keep-white-space-fixed"
                };
                pnlValueCell.Controls.Add(pnlValue);
                var pnlIcons = new Panel
                {
                    CssClass = "settings-info-group keep-white-space-fixed"
                };
                pnlValueCell.Controls.Add(pnlIcons);

                // Don't show help icon when not provided. (Help icon will be shown if macro resolution results in an empty string.)
                if (!String.IsNullOrWhiteSpace(keyInfo.KeyDescription))
                {
                    Label helpIcon = GetIcon("icon-question-circle", ResHelper.LocalizeString(keyInfo.KeyDescription));
                    pnlIcons.Controls.Add(helpIcon);
                }

                CMSCheckBox chkInherit = null;
                if (mSiteId > 0)
                {
                    // Wrap in update panel for inherit checkbox postback
                    var pnlValueUpdate = new UpdatePanel
                    {
                        ID = string.Format("pnlValueUpdate{0}{1}", groupCount, keyCount),
                        UpdateMode = UpdatePanelUpdateMode.Conditional,
                    };
                    pnlRow.Controls.Add(pnlValueUpdate);

                    // Add inherit checkbox
                    chkInherit = GetInheritCheckBox(groupCount, keyCount);
                    keyItem.InheritCheckBox = chkInherit;

                    pnlValueUpdate.ContentTemplateContainer.Controls.Add(chkInherit);

                    pnlValueUpdate.ContentTemplateContainer.Controls.Add(pnlValueCell);
                }
                else
                {
                    pnlRow.Controls.Add(pnlValueCell);

                    // Add "current site does not inherit the global value" warning for global settings
                    if (SiteContext.CurrentSite != null)
                    {
                        var isCurrentSiteValueInherited = SettingsKeyInfoProvider.IsValueInherited(keyInfo.KeyName, SiteContext.CurrentSiteID);
                        if (!isCurrentSiteValueInherited)
                        {
                            string inheritWarningText = String.Format(GetString("settings.currentsitedoesnotinherit"), ResHelper.LocalizeString(SiteContext.CurrentSite.DisplayName));
                            Label inheritWarningImage = GetIcon("icon-exclamation-triangle warning-icon", HTMLHelper.HTMLEncode(inheritWarningText));

                            pnlIcons.Controls.Add(inheritWarningImage);
                        }
                    }
                }

                // Add explanation text
                if (!String.IsNullOrWhiteSpace(keyItem.ExplanationText))
                {
                    Panel pnlExplanationText = new Panel
                    {
                        CssClass = "explanation-text-settings"
                    };
                    LocalizedLiteral explanationText = new LocalizedLiteral
                    {
                        Text = keyItem.ExplanationText
                    };
                    pnlExplanationText.Controls.Add(explanationText);
                    pnlRow.Controls.Add(pnlExplanationText);
                }

                pnlRow.Controls.Add(new LiteralControl(@"</div>"));

                // Get current values
                keyItem.KeyIsInherited = SettingsKeyInfoProvider.IsValueInherited(keyInfo.KeyName, SiteName);
                keyItem.KeyValue = SettingsKeyInfoProvider.GetValue(keyInfo.KeyName, SiteName);

                // Get value
                string keyValue;
                bool isInherited;
                if (RequestHelper.IsPostBack() && (chkInherit != null))
                {
                    isInherited = Request.Form[chkInherit.UniqueID] != null;
                    keyValue = isInherited ? SettingsKeyInfoProvider.GetValue(keyInfo.KeyName) : SettingsKeyInfoProvider.GetValue(keyInfo.KeyName, SiteName);
                }
                else
                {
                    isInherited = keyItem.KeyIsInherited;
                    keyValue = keyItem.KeyValue;

                    // Set the inherit checkbox state
                    if (!RequestHelper.IsPostBack() && chkInherit != null)
                    {
                        chkInherit.Checked = isInherited;
                    }
                }

                // Add value editing control
                var enabled = !isInherited;
                FormEngineUserControl control = GetFormEngineUserControl(keyInfo, groupCount, keyCount);
                if (control != null)
                {
                    // Add form engine value editing control
                    control.Value = keyValue;
                    pnlValue.Controls.Add(control);

                    // Set form control enabled value, does not work when moved before plcControl.Controls.Add(control)
                    control.Enabled = enabled;

                    keyItem.ValueControl = control;

                    if (chkInherit != null)
                    {
                        chkInherit.CheckedChanged += (sender, args) =>
                        {
                            control.Value = keyValue;
                        };
                    }
                }
                else
                {
                    // Add simple value editing control
                    switch (keyInfo.KeyType.ToLowerCSafe())
                    {
                        case "boolean":
                            // Add checkbox value editing control
                            var @checked = ValidationHelper.GetBoolean(keyValue, false);
                            CMSCheckBox chkValue = GetValueCheckBox(groupCount, keyCount, @checked, enabled);
                            pnlValue.Controls.Add(chkValue);

                            keyItem.ValueControl = chkValue;

                            if (chkInherit != null)
                            {
                                chkInherit.CheckedChanged += (sender, args) =>
                                {
                                    chkValue.Checked = @checked;
                                };
                            }
                            break;

                        case "longtext":
                            // Add text area value editing control
                            var longText = keyValue;
                            var txtValueTextArea = GetValueTextArea(groupCount, keyCount, longText, enabled);
                            if (txtValueTextArea != null)
                            {
                                // Text area control was loaded successfully
                                pnlValue.Controls.Add(txtValueTextArea);
                                keyItem.ValueControl = txtValueTextArea;
                                if (chkInherit != null)
                                {
                                    chkInherit.CheckedChanged += (sender, args) =>
                                    {
                                        txtValueTextArea.Text = longText;
                                    };
                                }
                            }
                            else
                            {
                                // Text area control was not loaded successfully
                                var errorLabel = new FormControlError
                                {
                                    ErrorTitle = "[Error loading the editing control, check the event log for more details]",
                                };
                                pnlValue.Controls.Add(errorLabel);
                            }
                            break;

                        default:
                            // Add textbox value editing control
                            var text = keyValue;
                            TextBox txtValue = GetValueTextBox(groupCount, keyCount, text, enabled);
                            pnlValue.Controls.Add(txtValue);

                            keyItem.ValueControl = txtValue;

                            if (chkInherit != null)
                            {
                                chkInherit.CheckedChanged += (sender, args) =>
                                {
                                    txtValue.Text = text;
                                };
                            }
                            break;
                    }
                }

                // Add label to the label cell when associated control has been resolved
                pnlLabelCell.Controls.Add(GetLabel(keyInfo, keyItem.ValueControl, groupCount, keyCount));

                // Add error label if KeyType is integer or validation expression defined or FormControl is used
                if ((keyInfo.KeyType == "int") || (keyInfo.KeyType == "double") || (keyItem.ValidationRegexPattern != null) || (control != null))
                {
                    Label lblError = GetLabelError(groupCount, keyCount);
                    pnlIcons.Controls.Add(lblError);
                    keyItem.ErrorLabel = lblError;
                }

                mKeyItems.Add(keyItem);
            }
        }

        // Show info message when other than global-only global keys are displayed
        if ((mSiteId <= 0) && (CategoryID > 0) && !hasOnlyGlobalKeys && AllowGlobalInfoMessage)
        {
            ShowInformation(GetString("settings.keys.globalsettingsnote"));
        }

        // Display export and reset links only if some groups were found.
        if (groupCount > 0)
        {
            // Add reset link if required
            if (!RequestHelper.IsPostBack() && QueryHelper.GetInteger("resettodefault", 0) == 1)
            {
                ShowInformation(GetString("Settings-Keys.ValuesWereResetToDefault"));
            }
        }
        else
        {
            // Hide "These settings are global ..." message if no setting found in this group
            if (!string.IsNullOrEmpty(mSearchText))
            {
                var ltrScript = new Literal
                {
                    Text = ScriptHelper.GetScript("DisableHeaderActions();")
                };
                plcContent.Append(ltrScript);
                lblNoData.Visible = true;
            }
        }
    }
Esempio n. 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //add the localization control
            //NOTE: when this becomes a custom control, the control should be passed
            //in as a child

            /*
             * switch (this.Type)
             * {
             *  case DynamicEditType.HyperLink:
             *      LocalizedHyperLink hyperlink = new LocalizedHyperLink();
             *
             *      if (EditingActive)
             *      {
             *          //hyperlink text should just be simple [Go]
             *
             *      }
             *      hyperlink.Key = this.Key;
             *      hyperlink.NavigateUrl = this.NavigateUrl;
             *      hyperlink.ReplaceText = EmptyText;
             *      plhText.Controls.Add(hyperlink);
             *      break;
             *  default:
             *      LocalizedLiteral literal = new LocalizedLiteral();
             *      literal.Key = this.Key;
             *      literal.ReplaceText = EmptyText;
             *      plhText.Controls.Add(literal);
             *      break;
             *
             * }
             */


            LocalizedLiteral literal = new LocalizedLiteral();

            literal.Key = this.Key;

            if (IsFirst && EditingActive)
            {
                plhScriptOnce.Visible = true;
            }


            if (!EditingActive)
            {
                editingData.Visible     = false;
                plhScriptAlways.Visible = false;
            }
            else
            {
                literal.ReplaceText = EmptyText;


                btnCancel.OnClientClick = "jsi.aspdotnet.getControlInstance('" + this.UniqueID + "').lock(); return false;";

                containingData.Attributes.Add("onclick", "jsi.aspdotnet.getControlInstance('" + this.UniqueID + "').edit();");
                containingData.Attributes.Add("onmouseover", "this.style.cursor='pointer';");

                //show the required javascript for this control if it is the first instance of itself
                if (this.IsFirst)
                {
                    plhScriptOnce.Visible = true;
                }

                txtForEdit.CssClass = "tinymce" + EditType.ToString();

                //add the content inside the textbox as well
                // LocalizedLiteral literalInside = new LocalizedLiteral();
                //literalInside.Key = this.Key;

                //txtForEdit.Controls.Add(literalInside);
            }

            plhText.Controls.Add(literal);
        }
    private static void AddValueCell(Panel row, string valueText)
    {
        var valueCell = new Panel
        {
            CssClass = "editing-form-value-cell"
        };

        row.Controls.Add(valueCell);

        // A block wrap because of block content
        var valueControl = new Panel
        {
            CssClass = "form-control-text"
        };

        // Content may contain block HTML tags
        var localizedContent = new LocalizedLiteral
        {
            Text = valueText
        };

        valueControl.Controls.Add(localizedContent);

        valueCell.Controls.Add(valueControl);
    }
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        if (SettingsCategoryInfo == null)
        {
            plcContent.Append(GetString("settings.keys.nocategoryselected"));
            StopProcessing = true;
            return;
        }

        ScriptHelper.RegisterTooltip(Page);
        ScriptHelper.RegisterBootstrapTooltip(Page, ".info-icon > i");

        // Loop through all the groups in the category
        int  groupCount        = 0;
        bool hasOnlyGlobalKeys = true;
        var  groups            = GetGroups(SettingsCategoryInfo);

        foreach (var group in groups)
        {
            // Get keys
            var keys = GetKeys(group.CategoryID).ToArray();

            // Skip empty group
            if (!keys.Any())
            {
                continue;
            }

            groupCount++;

            // Add category panel for the group
            var pnlGroup = GetCategoryPanel(group, groupCount);
            plcContent.Append(pnlGroup);

            // Loop through all the keys in the group
            int keyCount = 0;
            foreach (var keyInfo in keys)
            {
                // Increase key number for unique control identification
                keyCount++;

                // Update flag when non-global-only key exists
                if (!keyInfo.KeyIsGlobal)
                {
                    hasOnlyGlobalKeys = false;
                }

                // Create key item
                var keyItem = new SettingsKeyItem
                {
                    ParentCategoryPanel    = pnlGroup,
                    KeyName                = keyInfo.KeyName,
                    KeyType                = keyInfo.KeyType,
                    ValidationRegexPattern = keyInfo.KeyValidation,
                    CategoryName           = group.CategoryName,
                    ExplanationText        = ResHelper.LocalizeString(keyInfo.KeyExplanationText)
                };


                Panel pnlRow = new Panel
                {
                    CssClass = "form-group"
                };
                pnlGroup.Controls.Add(pnlRow);

                // Add label cell to the beginning of the row
                var pnlLabelCell = new Panel
                {
                    CssClass = "editing-form-label-cell"
                };
                pnlRow.Controls.AddAt(0, pnlLabelCell);

                // Continue with the value cell
                pnlRow.Controls.Add(new LiteralControl(@"<div class=""editing-form-value-cell"">"));

                // Create placeholder for the editing control that may end up in an update panel
                var pnlValueCell = new Panel
                {
                    CssClass = "settings-group-inline keep-white-space-fixed"
                };
                var pnlValue = new Panel
                {
                    CssClass = "editing-form-control-nested-control keep-white-space-fixed"
                };
                pnlValueCell.Controls.Add(pnlValue);
                var pnlIcons = new Panel
                {
                    CssClass = "settings-info-group keep-white-space-fixed"
                };
                pnlValueCell.Controls.Add(pnlIcons);

                // Don't show help icon when not provided. (Help icon will be shown if macro resolution results in an empty string.)
                if (!String.IsNullOrWhiteSpace(keyInfo.KeyDescription))
                {
                    Label helpIcon = GetIcon("icon-question-circle", ResHelper.LocalizeString(keyInfo.KeyDescription));
                    pnlIcons.Controls.Add(helpIcon);
                }

                CMSCheckBox chkInherit = null;
                if (mSiteId > 0)
                {
                    // Wrap in update panel for inherit checkbox postback
                    var pnlValueUpdate = new UpdatePanel
                    {
                        ID         = string.Format("pnlValueUpdate{0}{1}", groupCount, keyCount),
                        UpdateMode = UpdatePanelUpdateMode.Conditional,
                    };
                    pnlRow.Controls.Add(pnlValueUpdate);

                    // Add inherit checkbox
                    chkInherit = GetInheritCheckBox(groupCount, keyCount);
                    keyItem.InheritCheckBox = chkInherit;

                    pnlValueUpdate.ContentTemplateContainer.Controls.Add(chkInherit);

                    pnlValueUpdate.ContentTemplateContainer.Controls.Add(pnlValueCell);
                }
                else
                {
                    pnlRow.Controls.Add(pnlValueCell);

                    // Add "current site does not inherit the global value" warning for global settings
                    if (SiteContext.CurrentSite != null)
                    {
                        var isCurrentSiteValueInherited = SettingsKeyInfoProvider.IsValueInherited(keyInfo.KeyName, SiteContext.CurrentSiteID);
                        if (!isCurrentSiteValueInherited)
                        {
                            string inheritWarningText  = String.Format(GetString("settings.currentsitedoesnotinherit"), ResHelper.LocalizeString(SiteContext.CurrentSite.DisplayName));
                            Label  inheritWarningImage = GetIcon("icon-exclamation-triangle warning-icon", HTMLHelper.HTMLEncode(inheritWarningText));

                            pnlIcons.Controls.Add(inheritWarningImage);
                        }
                    }
                }

                // Add explanation text
                if (!String.IsNullOrWhiteSpace(keyItem.ExplanationText))
                {
                    Panel pnlExplanationText = new Panel
                    {
                        CssClass = "explanation-text-settings"
                    };
                    LocalizedLiteral explanationText = new LocalizedLiteral
                    {
                        Text = keyItem.ExplanationText
                    };
                    pnlExplanationText.Controls.Add(explanationText);
                    pnlRow.Controls.Add(pnlExplanationText);
                }

                pnlRow.Controls.Add(new LiteralControl(@"</div>"));

                // Get current values
                keyItem.KeyIsInherited = SettingsKeyInfoProvider.IsValueInherited(keyInfo.KeyName, SiteName);
                keyItem.KeyValue       = SettingsKeyInfoProvider.GetValue(keyInfo.KeyName, SiteName);

                // Get value
                string keyValue;
                bool   isInherited;
                if (RequestHelper.IsPostBack() && (chkInherit != null))
                {
                    isInherited = Request.Form[chkInherit.UniqueID] != null;
                    keyValue    = isInherited ? SettingsKeyInfoProvider.GetValue(keyInfo.KeyName) : SettingsKeyInfoProvider.GetValue(keyInfo.KeyName, SiteName);
                }
                else
                {
                    isInherited = keyItem.KeyIsInherited;
                    keyValue    = keyItem.KeyValue;

                    // Set the inherit checkbox state
                    if (!RequestHelper.IsPostBack() && chkInherit != null)
                    {
                        chkInherit.Checked = isInherited;
                    }
                }

                // Add value editing control
                var enabled = !isInherited;
                FormEngineUserControl control = GetFormEngineUserControl(keyInfo, groupCount, keyCount);
                if (control != null)
                {
                    // Add form engine value editing control
                    control.Value = keyValue;
                    pnlValue.Controls.Add(control);

                    // Set form control enabled value, does not work when moved before plcControl.Controls.Add(control)
                    control.Enabled = enabled;

                    keyItem.ValueControl = control;

                    if (chkInherit != null)
                    {
                        chkInherit.CheckedChanged += (sender, args) =>
                        {
                            control.Value = keyValue;
                        };
                    }
                }
                else
                {
                    // Add simple value editing control
                    switch (keyInfo.KeyType.ToLowerCSafe())
                    {
                    case "boolean":
                        // Add checkbox value editing control
                        var         @checked = ValidationHelper.GetBoolean(keyValue, false);
                        CMSCheckBox chkValue = GetValueCheckBox(groupCount, keyCount, @checked, enabled);
                        pnlValue.Controls.Add(chkValue);

                        keyItem.ValueControl = chkValue;

                        if (chkInherit != null)
                        {
                            chkInherit.CheckedChanged += (sender, args) =>
                            {
                                chkValue.Checked = @checked;
                            };
                        }
                        break;

                    case "longtext":
                        // Add text area value editing control
                        var longText         = keyValue;
                        var txtValueTextArea = GetValueTextArea(groupCount, keyCount, longText, enabled);
                        if (txtValueTextArea != null)
                        {
                            // Text area control was loaded successfully
                            pnlValue.Controls.Add(txtValueTextArea);
                            keyItem.ValueControl = txtValueTextArea;
                            if (chkInherit != null)
                            {
                                chkInherit.CheckedChanged += (sender, args) =>
                                {
                                    txtValueTextArea.Text = longText;
                                };
                            }
                        }
                        else
                        {
                            // Text area control was not loaded successfully
                            var errorLabel = new FormControlError
                            {
                                ErrorTitle = "[Error loading the editing control, check the event log for more details]",
                            };
                            pnlValue.Controls.Add(errorLabel);
                        }
                        break;

                    default:
                        // Add textbox value editing control
                        var     text     = keyValue;
                        TextBox txtValue = GetValueTextBox(groupCount, keyCount, text, enabled);
                        pnlValue.Controls.Add(txtValue);

                        keyItem.ValueControl = txtValue;

                        if (chkInherit != null)
                        {
                            chkInherit.CheckedChanged += (sender, args) =>
                            {
                                txtValue.Text = text;
                            };
                        }
                        break;
                    }
                }

                // Add label to the label cell when associated control has been resolved
                pnlLabelCell.Controls.Add(GetLabel(keyInfo, keyItem.ValueControl, groupCount, keyCount));

                // Add error label if KeyType is integer or validation expression defined or FormControl is used
                if ((keyInfo.KeyType == "int") || (keyInfo.KeyType == "double") || (keyItem.ValidationRegexPattern != null) || (control != null))
                {
                    Label lblError = GetLabelError(groupCount, keyCount);
                    pnlIcons.Controls.Add(lblError);
                    keyItem.ErrorLabel = lblError;
                }

                mKeyItems.Add(keyItem);
            }
        }

        // Show info message when other than global-only global keys are displayed
        if ((mSiteId <= 0) && (CategoryID > 0) && !hasOnlyGlobalKeys && AllowGlobalInfoMessage)
        {
            ShowInformation(GetString("settings.keys.globalsettingsnote"));
        }

        // Display export and reset links only if some groups were found.
        if (groupCount > 0)
        {
            // Add reset link if required
            if (!RequestHelper.IsPostBack() && QueryHelper.GetInteger("resettodefault", 0) == 1)
            {
                ShowInformation(GetString("Settings-Keys.ValuesWereResetToDefault"));
            }
        }
        else
        {
            // Hide "These settings are global ..." message if no setting found in this group
            if (!string.IsNullOrEmpty(mSearchText))
            {
                var ltrScript = new Literal
                {
                    Text = ScriptHelper.GetScript("DisableHeaderActions();")
                };
                plcContent.Append(ltrScript);
                lblNoData.Visible = true;
            }
        }
    }