コード例 #1
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <param name="parentControl"></param>
        /// <returns></returns>
        public override System.Web.UI.Control[] CreateChildControls(System.Web.UI.Control parentControl)
        {
            RockDropDownList locationTypeList = new RockDropDownList();

            locationTypeList.Items.Clear();
            foreach (var value in DefinedTypeCache.Read(Rock.SystemGuid.DefinedType.GROUP_LOCATION_TYPE.AsGuid()).DefinedValues.OrderBy(a => a.Order).ThenBy(a => a.Value))
            {
                locationTypeList.Items.Add(new ListItem(value.Value, value.Guid.ToString()));
            }

            locationTypeList.Items.Insert(0, Rock.Constants.None.ListItem);

            locationTypeList.ID    = parentControl.ID + "_grouplocationType";
            locationTypeList.Label = "Address Type";
            parentControl.Controls.Add(locationTypeList);

            RockRadioButtonList addressPartRadioButtonList = new RockRadioButtonList();

            addressPartRadioButtonList.Items.Clear();
            addressPartRadioButtonList.BindToEnum <AddressNamePart>(false);

            // default to first one
            addressPartRadioButtonList.SelectedIndex = 0;
            addressPartRadioButtonList.ID            = parentControl.ID + "_addressPartRadioButtonList";
            addressPartRadioButtonList.Label         = "Address Part";
            addressPartRadioButtonList.Help          = "Select the part of the address to show in the grid, or select Full to show the full address";
            parentControl.Controls.Add(addressPartRadioButtonList);

            return(new System.Web.UI.Control[] { locationTypeList, addressPartRadioButtonList });
        }
コード例 #2
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <param name="parentControl"></param>
        /// <returns></returns>
        public override System.Web.UI.Control[] CreateChildControls(System.Web.UI.Control parentControl)
        {
            RockDropDownList ddlInteractionChannel = new RockDropDownList();

            ddlInteractionChannel.ID                    = parentControl.ID + "_ddlInteractionChannel";
            ddlInteractionChannel.Label                 = "Interaction Channel";
            ddlInteractionChannel.Required              = true;
            ddlInteractionChannel.AutoPostBack          = true;
            ddlInteractionChannel.SelectedIndexChanged += ddlInteractionChannel_SelectedIndexChanged;
            parentControl.Controls.Add(ddlInteractionChannel);

            var interactionChannelService = new InteractionChannelService(new RockContext());
            var noteTypes = interactionChannelService.Queryable().OrderBy(a => a.Name).Select(a => new
            {
                a.Id,
                a.Name
            }).ToList();

            ddlInteractionChannel.Items.Clear();
            ddlInteractionChannel.Items.Add(new ListItem());
            ddlInteractionChannel.Items.AddRange(noteTypes.Select(a => new ListItem(a.Name, a.Id.ToString())).ToArray());

            int?selectedInteractionChannelId = parentControl.Page.Request.Params[ddlInteractionChannel.UniqueID].AsIntegerOrNull();

            ddlInteractionChannel.SetValue(selectedInteractionChannelId);


            RockDropDownList ddlInteractionComponent = new RockDropDownList();

            ddlInteractionComponent.ID    = parentControl.ID + "_ddlInteractionComponent";
            ddlInteractionComponent.Label = "Interaction Component";
            ddlInteractionComponent.EnhanceForLongLists = true;
            parentControl.Controls.Add(ddlInteractionComponent);

            PopulateInteractionComponent(selectedInteractionChannelId, ddlInteractionComponent);
            RockTextBox tbOperation = new RockTextBox();

            tbOperation.Label = "Operation";
            tbOperation.ID    = parentControl.ID + "_tbOperation";
            parentControl.Controls.Add(tbOperation);


            RockRadioButtonList rblSelectionMode = new RockRadioButtonList();

            rblSelectionMode.ID    = parentControl.ID + "rblSelectionMode";
            rblSelectionMode.Label = "Selection Mode";
            rblSelectionMode.BindToEnum <FirstLastInteraction>();
            rblSelectionMode.SetValue(FirstLastInteraction.First.ConvertToInt());
            parentControl.Controls.Add(rblSelectionMode);

            return(new System.Web.UI.Control[] { ddlInteractionChannel, ddlInteractionComponent, tbOperation, rblSelectionMode });
        }
コード例 #3
0
ファイル: AddressSelect.cs プロジェクト: waldo2590/Rock
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <param name="parentControl"></param>
        /// <returns></returns>
        public override System.Web.UI.Control[] CreateChildControls(System.Web.UI.Control parentControl)
        {
            RockDropDownList locationTypeList = new RockDropDownList();

            locationTypeList.Items.Clear();
            foreach (var value in DefinedTypeCache.Get(Rock.SystemGuid.DefinedType.GROUP_LOCATION_TYPE.AsGuid()).DefinedValues.OrderBy(a => a.Order).ThenBy(a => a.Value))
            {
                locationTypeList.Items.Add(new ListItem(value.Value, value.Guid.ToString()));
            }

            locationTypeList.ID            = parentControl.ID + "_grouplocationType";
            locationTypeList.Label         = "Address Type";
            locationTypeList.SelectedIndex = 0;
            parentControl.Controls.Add(locationTypeList);

            RockRadioButtonList addressPartRadioButtonList = new RockRadioButtonList();

            addressPartRadioButtonList.Items.Clear();
            addressPartRadioButtonList.BindToEnum <RockUdfHelper.AddressNamePart>(false);

            // Localises the radio button list by modifying the text Value of radio buttons
            Dictionary <string, string> newLabels = new Dictionary <string, string>();
            var globalAttributesCache             = GlobalAttributesCache.Get();
            var defaultCountry = (!string.IsNullOrWhiteSpace(globalAttributesCache.OrganizationCountry)) ? globalAttributesCache.OrganizationCountry : "US";
            var countryValue   = DefinedTypeCache.Get(new Guid(SystemGuid.DefinedType.LOCATION_COUNTRIES))
                                 .DefinedValues
                                 .Where(v => v.Value.Equals(defaultCountry, StringComparison.OrdinalIgnoreCase))
                                 .FirstOrDefault();

            if (countryValue != null)
            {
                if (!newLabels.ContainsKey("City"))
                {
                    newLabels.Add("City", countryValue.GetAttributeValue("CityLabel"));
                }

                if (!newLabels.ContainsKey("Region"))
                {
                    newLabels.Add("Region", countryValue.GetAttributeValue("StateLabel"));
                }

                if (!newLabels.ContainsKey("PostalCode"))
                {
                    newLabels.Add("PostalCode", countryValue.GetAttributeValue("PostalCodeLabel"));
                }
            }

            foreach (KeyValuePair <string, string> pair in newLabels)
            {
                string oldValue = pair.Key.SplitCase();
                string newValue = pair.Value.SplitCase();
                var    listItem = addressPartRadioButtonList.Items.FindByText(oldValue);
                if (listItem != null)
                {
                    listItem.Text = newValue;
                }
            }

            // default to first one
            addressPartRadioButtonList.SelectedIndex = 0;
            addressPartRadioButtonList.ID            = parentControl.ID + "_addressPartRadioButtonList";
            addressPartRadioButtonList.Label         = "Address Part";
            addressPartRadioButtonList.Help          = "Select the part of the address to show in the grid, or select Full to show the full address";
            parentControl.Controls.Add(addressPartRadioButtonList);

            return(new System.Web.UI.Control[] { locationTypeList, addressPartRadioButtonList });
        }