Наследование: System.Web.UI.WebControls.CompositeControl, IRockControl
Пример #1
0
        private void GenerateAddAddressPanel()
        {
            _pnlAddAddress = new Panel
            {
                ID       = $"{this.ClientID}{nameof( _pnlAddAddress )}",
                CssClass = "mt-3 well",
                Visible  = false,
            };
            Controls.Add(_pnlAddAddress);

            _txtName = new RockTextBox
            {
                ID          = $"{this.ClientID}{nameof( _txtName )}",
                CssClass    = "mb-3",
                Placeholder = "Location Name",
            };
            _pnlAddAddress.Controls.Add(_txtName);

            _acNewAddress = new AddressControl
            {
                ID       = $"{this.ClientID}{nameof( _acNewAddress )}",
                Required = IsAddressRequired,
            };
            _pnlAddAddress.Controls.Add(_acNewAddress);

            _avcAddressAttributeValues = new AttributeValuesContainer
            {
                ID = $"{this.ClientID}{nameof( _avcAddressAttributeValues )}",
            };
            _pnlAddAddress.Controls.Add(_avcAddressAttributeValues);

            _btnAdd = new BootstrapButton
            {
                ID       = $"{this.ClientID}{nameof( _btnAdd )}",
                Text     = "Add",
                CssClass = "btn btn-xs btn-primary mr-2",
            };
            _btnAdd.Click += btnAdd_Click;
            _pnlAddAddress.Controls.Add(_btnAdd);

            _btnCancel = new LinkButton
            {
                ID               = $"{this.ClientID}{nameof( _btnCancel )}",
                Text             = "Cancel",
                CssClass         = "btn btn-xs btn-link",
                CausesValidation = false,
            };
            _btnCancel.Click += btnCancel_Click;
            _pnlAddAddress.Controls.Add(_btnCancel);

            _avcAddressAttributeValues.AddEditControls(new Location {
                LocationTypeValueId = LocationTypeValueId, ParentLocationId = ParentLocationId
            });
        }
Пример #2
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Controls.Clear();

            this.CssClass = "picker picker-select rollover-container";

            _hfLocationId = new HiddenField { ID = "hfLocationId" };
            this.Controls.Add( _hfLocationId );

            _btnPickerLabel = new HtmlAnchor { ID = "btnPickerLabel" };
            _btnPickerLabel.Attributes["class"] = "picker-label";
            this.Controls.Add( _btnPickerLabel );

            _btnSelectNone = new HtmlAnchor();
            _btnSelectNone.Attributes["class"] = "picker-select-none";
            _btnSelectNone.ID = string.Format( "btnSelectNone_{0}", this.ID );
            _btnSelectNone.InnerHtml = "<i class='fa fa-times'></i>";
            _btnSelectNone.CausesValidation = false;
            _btnSelectNone.Style[HtmlTextWriterStyle.Display] = "none";
            _btnSelectNone.ServerClick += _btnSelectNone_ServerClick;
            this.Controls.Add( _btnSelectNone );

            _hfPanelIsVisible = new HiddenFieldWithClass();
            _hfPanelIsVisible.CssClass = "js-picker-menu-is-visible";
            _hfPanelIsVisible.ID = string.Format( "hfPanelIsVisible_{0}", this.ID );
            this.Controls.Add( _hfPanelIsVisible );

            // PickerMenu (DropDown menu)
            _pnlPickerMenu = new Panel { ID = "pnlPickerMenu" };
            _pnlPickerMenu.CssClass = "picker-menu dropdown-menu";
            this.Controls.Add( _pnlPickerMenu );
            SetPickerOnClick();

            // Address Entry
            _pnlAddressEntry = new Panel { ID = "pnlAddressEntry" };
            _pnlAddressEntry.CssClass = "locationpicker-address-entry";
            _pnlPickerMenu.Controls.Add( _pnlAddressEntry );

            _acAddress = new AddressControl { ID = "acAddress" };
            _pnlAddressEntry.Controls.Add( _acAddress );

            // picker actions
            _pnlPickerActions = new Panel { ID = "pnlPickerActions", CssClass = "picker-actions" };
            _pnlPickerMenu.Controls.Add( _pnlPickerActions );
            _btnSelect = new LinkButton { ID = "btnSelect", CssClass = "btn btn-xs btn-primary", Text = "Select", CausesValidation = false };
            _btnSelect.Click += _btnSelect_Click;
            _pnlPickerActions.Controls.Add( _btnSelect );
            _btnCancel = new LinkButton { ID = "btnCancel", CssClass = "btn btn-xs btn-link", Text = "Cancel" };
            _btnCancel.OnClientClick = string.Format( "$('#{0}').hide(); $('#{1}').val('false'); Rock.dialogs.updateModalScrollBar('{0}'); return false;", _pnlPickerMenu.ClientID, _hfPanelIsVisible.ClientID );
            _pnlPickerActions.Controls.Add( _btnCancel );
        }
Пример #3
0
        /// <summary>
        /// Creates the person field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="setValue">if set to <c>true</c> [set value].</param>
        /// <param name="fieldValue">The field value.</param>
        private void CreatePersonField( RegistrationTemplateFormField field, bool setValue, object fieldValue )
        {
            switch ( field.PersonFieldType )
            {
                case RegistrationPersonFieldType.FirstName:
                    {
                        var tbFirstName = new RockTextBox();
                        tbFirstName.ID = "tbFirstName";
                        tbFirstName.Label = "First Name";
                        tbFirstName.Required = field.IsRequired;
                        tbFirstName.ValidationGroup = BlockValidationGroup;
                        tbFirstName.AddCssClass( "js-first-name" );
                        phRegistrantControls.Controls.Add( tbFirstName );

                        if ( setValue && fieldValue != null )
                        {
                            tbFirstName.Text = fieldValue.ToString();
                        }

                        break;
                    }

                case RegistrationPersonFieldType.LastName:
                    {
                        var tbLastName = new RockTextBox();
                        tbLastName.ID = "tbLastName";
                        tbLastName.Label = "Last Name";
                        tbLastName.Required = field.IsRequired;
                        tbLastName.ValidationGroup = BlockValidationGroup;
                        phRegistrantControls.Controls.Add( tbLastName );

                        if ( setValue && fieldValue != null )
                        {
                            tbLastName.Text = fieldValue.ToString();
                        }

                        break;
                    }

                case RegistrationPersonFieldType.Campus:
                    {
                        var cpHomeCampus = new CampusPicker();
                        cpHomeCampus.ID = "cpHomeCampus";
                        cpHomeCampus.Label = "Campus";
                        cpHomeCampus.Required = field.IsRequired;
                        cpHomeCampus.ValidationGroup = BlockValidationGroup;
                        cpHomeCampus.Campuses = CampusCache.All();

                        phRegistrantControls.Controls.Add( cpHomeCampus );

                        if ( setValue && fieldValue != null )
                        {
                            cpHomeCampus.SelectedCampusId = fieldValue.ToString().AsIntegerOrNull();
                        }
                        break;
                    }

                case RegistrationPersonFieldType.Address:
                    {
                        var acAddress = new AddressControl();
                        acAddress.ID = "acAddress";
                        acAddress.Label = "Address";
                        acAddress.UseStateAbbreviation = true;
                        acAddress.UseCountryAbbreviation = false;
                        acAddress.Required = field.IsRequired;
                        acAddress.ValidationGroup = BlockValidationGroup;

                        phRegistrantControls.Controls.Add( acAddress );

                        if ( setValue && fieldValue != null )
                        {
                            var value = fieldValue.ToString().FromJsonOrNull<Location>();
                            acAddress.SetValues( value );
                        }

                        break;
                    }

                case RegistrationPersonFieldType.Email:
                    {
                        var tbEmail = new EmailBox();
                        tbEmail.ID = "tbEmail";
                        tbEmail.Label = "Email";
                        tbEmail.Required = field.IsRequired;
                        tbEmail.ValidationGroup = BlockValidationGroup;
                        phRegistrantControls.Controls.Add( tbEmail );

                        if ( setValue && fieldValue != null )
                        {
                            tbEmail.Text = fieldValue.ToString();
                        }

                        break;
                    }

                case RegistrationPersonFieldType.Birthdate:
                    {
                        var bpBirthday = new BirthdayPicker();
                        bpBirthday.ID = "bpBirthday";
                        bpBirthday.Label = "Birthday";
                        bpBirthday.Required = field.IsRequired;
                        bpBirthday.ValidationGroup = BlockValidationGroup;
                        phRegistrantControls.Controls.Add( bpBirthday );

                        if ( setValue && fieldValue != null )
                        {
                            var value = fieldValue as DateTime?;
                            bpBirthday.SelectedDate = value;
                        }

                        break;
                    }

                case RegistrationPersonFieldType.Gender:
                    {
                        var ddlGender = new RockDropDownList();
                        ddlGender.ID = "ddlGender";
                        ddlGender.Label = "Gender";
                        ddlGender.Required = field.IsRequired;
                        ddlGender.ValidationGroup = BlockValidationGroup;
                        ddlGender.BindToEnum<Gender>( false );

                        // change the 'Unknow' value to be blank instead
                        ddlGender.Items.FindByValue( "0" ).Text = string.Empty;

                        phRegistrantControls.Controls.Add( ddlGender );

                        if ( setValue && fieldValue != null )
                        {
                            var value = fieldValue.ToString().ConvertToEnumOrNull<Gender>() ?? Gender.Unknown;
                            ddlGender.SetValue( value.ConvertToInt() );
                        }

                        break;
                    }

                case RegistrationPersonFieldType.MaritalStatus:
                    {
                        var ddlMaritalStatus = new RockDropDownList();
                        ddlMaritalStatus.ID = "ddlMaritalStatus";
                        ddlMaritalStatus.Label = "Marital Status";
                        ddlMaritalStatus.Required = field.IsRequired;
                        ddlMaritalStatus.ValidationGroup = BlockValidationGroup;
                        ddlMaritalStatus.BindToDefinedType( DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS.AsGuid() ), true );
                        phRegistrantControls.Controls.Add( ddlMaritalStatus );

                        if ( setValue && fieldValue != null )
                        {
                            var value = fieldValue.ToString().AsInteger();
                            ddlMaritalStatus.SetValue( value );
                        }

                        break;
                    }

                case RegistrationPersonFieldType.MobilePhone:
                    {
                        var dv = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE );
                        if ( dv != null )
                        {
                            var ppMobile = new PhoneNumberBox();
                            ppMobile.ID = "ppMobile";
                            ppMobile.Label = dv.Value;
                            ppMobile.Required = field.IsRequired;
                            ppMobile.ValidationGroup = BlockValidationGroup;
                            ppMobile.CountryCode = PhoneNumber.DefaultCountryCode();

                            phRegistrantControls.Controls.Add( ppMobile );

                            if ( setValue && fieldValue != null )
                            {
                                var value = fieldValue as PhoneNumber;
                                if ( value != null )
                                {
                                    ppMobile.CountryCode = value.CountryCode;
                                    ppMobile.Number = value.ToString();
                                }
                            }
                        }

                        break;
                    }
                case RegistrationPersonFieldType.HomePhone:
                    {
                        var dv = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME );
                        if ( dv != null )
                        {
                            var ppHome = new PhoneNumberBox();
                            ppHome.ID = "ppHome";
                            ppHome.Label = dv.Value;
                            ppHome.Required = field.IsRequired;
                            ppHome.ValidationGroup = BlockValidationGroup;
                            ppHome.CountryCode = PhoneNumber.DefaultCountryCode();

                            phRegistrantControls.Controls.Add( ppHome );

                            if ( setValue && fieldValue != null )
                            {
                                var value = fieldValue as PhoneNumber;
                                if ( value != null )
                                {
                                    ppHome.CountryCode = value.CountryCode;
                                    ppHome.Number = value.ToString();
                                }
                            }
                        }

                        break;
                    }

                case RegistrationPersonFieldType.WorkPhone:
                    {
                        var dv = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_WORK );
                        if ( dv != null )
                        {
                            var ppWork = new PhoneNumberBox();
                            ppWork.ID = "ppWork";
                            ppWork.Label = dv.Value;
                            ppWork.Required = field.IsRequired;
                            ppWork.ValidationGroup = BlockValidationGroup;
                            ppWork.CountryCode = PhoneNumber.DefaultCountryCode();

                            phRegistrantControls.Controls.Add( ppWork );

                            if ( setValue && fieldValue != null )
                            {
                                var value = fieldValue.ToString().FromJsonOrNull<PhoneNumber>();
                                if ( value != null )
                                {
                                    ppWork.CountryCode = value.CountryCode;
                                    ppWork.Number = value.ToString();
                                }
                            }
                        }

                        break;
                    }
            }
        }
Пример #4
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Controls.Clear();

            this.CssClass = "picker picker-select rollover-container";

            _hfLocationId = new HiddenField {
                ID = "hfLocationId"
            };
            this.Controls.Add(_hfLocationId);

            _btnPickerLabel = new HtmlAnchor {
                ID = "btnPickerLabel"
            };
            _btnPickerLabel.Attributes["class"] = "picker-label";
            this.Controls.Add(_btnPickerLabel);

            _btnSelectNone = new HtmlAnchor();
            _btnSelectNone.Attributes["class"] = "picker-select-none";
            _btnSelectNone.ID               = string.Format("btnSelectNone_{0}", this.ID);
            _btnSelectNone.InnerHtml        = "<i class='fa fa-times'></i>";
            _btnSelectNone.CausesValidation = false;
            _btnSelectNone.Style[HtmlTextWriterStyle.Display] = "none";
            _btnSelectNone.ServerClick += _btnSelectNone_ServerClick;
            this.Controls.Add(_btnSelectNone);

            _hfPanelIsVisible          = new HiddenFieldWithClass();
            _hfPanelIsVisible.CssClass = "js-picker-menu-is-visible";
            _hfPanelIsVisible.ID       = string.Format("hfPanelIsVisible_{0}", this.ID);
            this.Controls.Add(_hfPanelIsVisible);

            // PickerMenu (DropDown menu)
            _pnlPickerMenu = new Panel {
                ID = "pnlPickerMenu"
            };
            _pnlPickerMenu.CssClass = "picker-menu dropdown-menu";
            this.Controls.Add(_pnlPickerMenu);
            SetPickerOnClick();

            // Address Entry
            _pnlAddressEntry = new Panel {
                ID = "pnlAddressEntry"
            };
            _pnlAddressEntry.CssClass = "locationpicker-address-entry";
            _pnlPickerMenu.Controls.Add(_pnlAddressEntry);

            _acAddress = new AddressControl {
                ID = "acAddress"
            };
            _pnlAddressEntry.Controls.Add(_acAddress);

            // picker actions
            _pnlPickerActions = new Panel {
                ID = "pnlPickerActions", CssClass = "picker-actions"
            };
            _pnlPickerMenu.Controls.Add(_pnlPickerActions);
            _btnSelect = new LinkButton {
                ID = "btnSelect", CssClass = "btn btn-xs btn-primary", Text = "Select", CausesValidation = false
            };
            _btnSelect.Click += _btnSelect_Click;
            _pnlPickerActions.Controls.Add(_btnSelect);
            _btnCancel = new LinkButton {
                ID = "btnCancel", CssClass = "btn btn-xs btn-link", Text = "Cancel"
            };
            _btnCancel.OnClientClick = string.Format("$('#{0}').hide(); $('#{1}').val('false'); Rock.dialogs.updateModalScrollBar('{2}'); return false;", _pnlPickerMenu.ClientID, _hfPanelIsVisible.ClientID, this.ClientID);
            _pnlPickerActions.Controls.Add(_btnCancel);
        }