using System; using System.Web.UI; using System.Web.UI.WebControls; using CMS.FormControls; using CMS.SettingsProvider; using CMS.UIControls; public partial class CMSFormControls_Classes_SelectClass : FormEngineUserControl { #region "Variables" private bool mOnlyCustomTables = false; private bool mOnlyDocumentTypes = true; private string mWhereCondition = String.Empty; #endregion #region "Public properties" /// /// Gets or sets the selector where condition. /// public string WhereCondition { get { return mWhereCondition; } set { mWhereCondition = value; } } /// /// Gets or sets the enabled state of the control. /// public override bool Enabled { get { return base.Enabled; } set { base.Enabled = value; if (uniSelector != null) { uniSelector.Enabled = value; } } } /// /// Returns ClientID of the textbox with classnames. /// public override string ValueElementID { get { return uniSelector.TextBoxSelect.ClientID; } } /// /// Gets or sets the field value. /// public override object Value { get { return uniSelector.Value; } set { if (uniSelector == null) { pnlUpdate.LoadContainer(); } uniSelector.Value = value; } } /// /// Gets inner uniselector. /// public UniSelector UniSelector { get { return uniSelector; } } /// /// Gets the inner DDL control. /// public DropDownList DropDownSingleSelect { get { return uniSelector.DropDownSingleSelect; } } /// /// If true, only Custom tables are loaded. /// public bool OnlyCustomTables { get { return mOnlyCustomTables; } set { mOnlyCustomTables = value; mOnlyDocumentTypes = !value; } } /// /// If true, only Document types are loaded. /// public bool OnlyDocumentTypes { get { return mOnlyDocumentTypes; } set { mOnlyDocumentTypes = value; mOnlyCustomTables = !value; } } /// /// Gets or sets whether (all) field is in dropdownlist. /// public bool DisplayAllValue { get { return uniSelector.AllowAll; } set { uniSelector.AllowAll = value; } } /// /// Gets or sets whether (none) field is in dropdownlist. /// public bool DisplayNoneValue { get { return uniSelector.AllowEmpty; } set { uniSelector.AllowEmpty = value; } } /// /// Indicates if control is used on live site. /// public override bool IsLiveSite { get { return base.IsLiveSite; } set { EnsureChildControls(); base.IsLiveSite = value; UniSelector.IsLiveSite = value; } } #endregion protected void Page_Load(object sender, EventArgs e) { if (StopProcessing) { uniSelector.StopProcessing = true; } else { ReloadData(); } } /// /// Reloads the data in the selector. /// public void ReloadData() { ReloadData(false); } /// /// Reloads the data in the selector. /// /// If true, UniSelector is also reloaded public void ReloadData(bool reloadUniSelector) { uniSelector.IsLiveSite = IsLiveSite; string whereCondition = String.Empty; if (OnlyDocumentTypes) { whereCondition = "(ClassIsDocumentType = 1)"; } else if (OnlyCustomTables) { whereCondition = "(ClassIsCustomTable = 1)"; } // Combine default where condition with external if (!String.IsNullOrEmpty(WhereCondition)) { whereCondition = SqlHelperClass.AddWhereCondition(whereCondition, WhereCondition); } uniSelector.WhereCondition = whereCondition; if (reloadUniSelector) { uniSelector.Reload(true); } } }