using System; using System.Data; using System.Collections; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using CMS.FormControls; using CMS.GlobalHelper; using CMS.SettingsProvider; public partial class CMSModules_Widgets_FormControls_SelectZoneType : FormEngineUserControl { #region "Variables" private string mSelectedValue = "None"; #endregion #region "Public properties" /// /// Gets or sets the value that indicates whether current zone is on dashboard template. /// public bool IsDashboard { get { return ValidationHelper.GetBoolean(GetValue("IsDashboard"), false); } set { SetValue("IsDashboard", value); } } /// /// Sets the property value of the control, setting the value affects only local property value. /// /// Property name to set /// New property value public override void SetValue(string propertyName, object value) { base.SetValue(propertyName, value); if (CMSString.Compare(propertyName, "isdashboard", true) == 0) { FillItemsCollection(); } } /// /// Gets or sets field value. /// public override object Value { get { EnsureChildControls(); return rblOptions.SelectedValue; } set { EnsureChildControls(); mSelectedValue = ValidationHelper.GetString(value, String.Empty); rblOptions.SelectedValue = mSelectedValue; } } #endregion #region "Methods" /// /// OnLoad - ensures child controls. /// protected void Page_Load(object sender, EventArgs e) { EnsureChildControls(); } /// /// Creates child controls. /// protected override void CreateChildControls() { FillItemsCollection(); base.CreateChildControls(); } /// /// Fills item collection with dependence on current settings. /// private void FillItemsCollection() { rblOptions.Items.Clear(); ListItem li = null; li = new ListItem(GetString("widgets.zonetype.none"), "None"); li.Attributes.Add("onclick", "ShowZoneTypeWarning();"); rblOptions.Items.Add(li); if (!IsDashboard) { li = new ListItem(GetString("widgets.zonetype.user"), "User"); li.Attributes.Add("onclick", "ShowZoneTypeWarning();"); rblOptions.Items.Add(li); li = new ListItem(GetString("widgets.zonetype.editor"), "Editor"); li.Attributes.Add("onclick", "ShowZoneTypeWarning();"); rblOptions.Items.Add(li); li = new ListItem(GetString("widgets.zonetype.group"), "Group"); li.Attributes.Add("onclick", "ShowZoneTypeWarning();"); rblOptions.Items.Add(li); } else { li = new ListItem(GetString("widgets.zonetype.dashboard"), "Dashboard"); li.Attributes.Add("onclick", "ShowZoneTypeWarning();"); rblOptions.Items.Add(li); } rblOptions.SelectedValue = mSelectedValue; } #endregion }