using System.Web.UI.WebControls; using CMS.FormControls; using CMS.GlobalHelper; public partial class CMSModules_REST_FormControls_SelectRESTAuthentication : FormEngineUserControl { private string authentication = ""; protected override void CreateChildControls() { base.CreateChildControls(); ReloadData(); } /// /// Gets or sets the enabled state of the control. /// public override bool Enabled { get { return base.Enabled; } set { base.Enabled = value; drpSelectAuthentication.Enabled = value; } } /// /// Gets or sets field value. /// public override object Value { get { return ValidationHelper.GetString(drpSelectAuthentication.SelectedValue, ""); } set { authentication = ValidationHelper.GetString(value, ""); ReloadData(); } } /// /// Returns true if user control is valid. /// public override bool IsValid() { return true; } /// /// Returns ClientID of the DropDownList with authentication. /// public override string ValueElementID { get { return drpSelectAuthentication.ClientID; } } /// /// Loads drop down list with data. /// private void ReloadData() { if (drpSelectAuthentication.Items.Count == 0) { drpSelectAuthentication.Items.Add(new ListItem(GetString("rest.basicauthentication"), "basic")); drpSelectAuthentication.Items.Add(new ListItem(GetString("rest.formsauthentication"), "forms")); } // Preselect value ListItem selectedItem = drpSelectAuthentication.Items.FindByValue(authentication); if (selectedItem != null) { drpSelectAuthentication.ClearSelection(); selectedItem.Selected = true; } else { drpSelectAuthentication.SelectedIndex = 0; } } }