상속: WebControl
예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            TextBox nickNameBox = new TextBox() { ID = "nickNameBox" };
            TextBox nameBox = new TextBox() { ID = "nameBox" };
            TextBox sirNameBox = new TextBox() { ID = "sirNameBox" };
            TextBox emailBox = new TextBox { ID = "emailBox" };
            Label registrationFormLabel = new Label { Text = "Registration form:" };
            Label nicknameLabel = new Label { Text = "Nick Name:" };
            Label nameLabel = new Label { Text = "First name:" };
            Label sirnameLabel = new Label { Text = "Last name:" };
            Label dateOfBirthLabel = new Label { Text = "Date of birth:" };
            Label emailLabel = new Label { Text = "E-mail:" };
            Label countryLabel = new Label { Text = "Country:" };
            Label cityLabel = new Label { Text = "City:" };
            Label validationSummaryLabel = new Label { Text = "Validation Summary:" };

            RegularExpressionValidator emailvalidator = new RegularExpressionValidator() { ValidationExpression = @"[a-zA-Z_0-9.-]+\@[a-zA-Z_0-9.-]+\.\w+", ControlToValidate = "emailBox", ForeColor = Color.Crimson, ErrorMessage = "Enter correct email please..." };
            RequiredFieldValidator requiredEmail = new RequiredFieldValidator() { ControlToValidate = "emailBox", ForeColor = Color.Crimson, ErrorMessage = "Enter e-mail please..." };
            RequiredFieldValidator requiredCountry = new RequiredFieldValidator() { ControlToValidate = "country", ForeColor = Color.Crimson, ErrorMessage = "Select country please..." };
            RequiredFieldValidator requiredCity = new RequiredFieldValidator() { ControlToValidate = "city", ForeColor = Color.Crimson, ErrorMessage = "Select city please..." };
            RequiredFieldValidator requiredNickname = new RequiredFieldValidator() { ControlToValidate = "nickNameBox", ForeColor = Color.Crimson, ErrorMessage = "Enter nickname please..." };
            RequiredFieldValidator requiredName = new RequiredFieldValidator() { ControlToValidate = "nameBox", ForeColor = Color.Crimson, ErrorMessage = "Enter first name please..." };
            RequiredFieldValidator requiredSirname = new RequiredFieldValidator() { ControlToValidate = "sirNameBox", ForeColor = Color.Crimson, ErrorMessage = "Enter last name please..." };
            RequiredFieldValidator requiredDate = new RequiredFieldValidator() { ControlToValidate = "birthDateBox", ForeColor = Color.Crimson, ErrorMessage = "Select the date please..." };
            CompareValidator nameToNick = new CompareValidator() { ControlToValidate = "nameBox", ControlToCompare = "nickNameBox", Operator = ValidationCompareOperator.NotEqual, ForeColor = Color.Crimson, ErrorMessage = "Shouldn`t be equal to nickname!" };
            CompareValidator sirnameToName = new CompareValidator() { ControlToValidate = "sirNameBox", ControlToCompare = "nameBox", Operator = ValidationCompareOperator.NotEqual, ForeColor = Color.Crimson, ErrorMessage = "Shouldn`t be equal to name!" };
            RangeValidator dateValidator = new RangeValidator() { ControlToValidate = "birthDateBox",MinimumValue = new DateTime(1960,12,1).ToShortDateString(),MaximumValue = DateTime.Now.ToShortDateString(),Type=ValidationDataType.Date, ForeColor = Color.Crimson, ErrorMessage = "Date of birth should be between 12/1/1960 and " + DateTime.Now.ToShortDateString() };
            CompareValidator notDefaultCountry = new CompareValidator() { ControlToValidate = "country", ValueToCompare = "Choose from there", Operator = ValidationCompareOperator.NotEqual, ForeColor = Color.Crimson, ErrorMessage = "Please select country!" };
            CompareValidator notDefaultCity = new CompareValidator() { ControlToValidate = "city", ValueToCompare = "Choose country first", Operator = ValidationCompareOperator.NotEqual, ForeColor = Color.Crimson, ErrorMessage = "Please, select city!" };

            ValidationSummary summary = new ValidationSummary() { ForeColor = Color.Crimson };

            Button submitButton = new Button();

            registrationFormLabel.Style["Position"] = "Absolute";
            registrationFormLabel.Style["Top"] = "25px";
            registrationFormLabel.Style["Left"] = "100px";
            registrationFormLabel.Font.Size = 24;
            registrationFormLabel.Font.Bold = true;

            nicknameLabel.Style["Position"] = "Absolute";
            nicknameLabel.Style["Top"] = "90px";
            nicknameLabel.Style["Left"] = "100px";
            nickNameBox.Style["Position"] = "Absolute";
            nickNameBox.Style["Top"] = "90px";
            nickNameBox.Style["Left"] = "250px";
            requiredNickname.Style["Position"] = "Absolute";
            requiredNickname.Style["Top"] = "90px";
            requiredNickname.Style["Left"] = "550px";

            nameLabel.Style["Position"] = "Absolute";
            nameLabel.Style["Top"] = "125px";
            nameLabel.Style["Left"] = "100px";
            nameBox.Style["Position"] = "Absolute";
            nameBox.Style["Top"] = "125px";
            nameBox.Style["Left"] = "250px";
            requiredName.Style["Position"] = "Absolute";
            requiredName.Style["Top"] = "125px";
            requiredName.Style["Left"] = "550px";
            nameToNick.Style["Position"] = "Absolute";
            nameToNick.Style["Top"] = "125px";
            nameToNick.Style["Left"] = "550px";

            sirnameLabel.Style["Position"] = "Absolute";
            sirnameLabel.Style["Top"] = "160px";
            sirnameLabel.Style["Left"] = "100px";
            sirNameBox.Style["Position"] = "Absolute";
            sirNameBox.Style["Top"] = "160px";
            sirNameBox.Style["Left"] = "250px";
            requiredSirname.Style["Position"] = "Absolute";
            requiredSirname.Style["Top"] = "160px";
            requiredSirname.Style["Left"] = "550px";
            sirnameToName.Style["Position"] = "Absolute";
            sirnameToName.Style["Top"] = "160px";
            sirnameToName.Style["Left"] = "550px";

            dateOfBirthLabel.Style["Position"] = "Absolute";
            dateOfBirthLabel.Style["Top"] = "195px";
            dateOfBirthLabel.Style["Left"] = "100px";
            birthDateBox.Style["Position"] = "Absolute";
            birthDateBox.Style["Top"] = "195px";
            birthDateBox.Style["Left"] = "250px";
            calendar.Style["Position"] = "Absolute";
            calendar.Style["Top"] = "230px";
            calendar.Style["Left"] = "250px";
            calendar.SelectionChanged += Calendar1_SelectionChanged;
            dateValidator.Style["Position"] = "Absolute";
            dateValidator.Style["Top"] = "195px";
            dateValidator.Style["Left"] = "550px";
            requiredDate.Style["Position"] = "Absolute";
            requiredDate.Style["Top"] = "195px";
            requiredDate.Style["Left"] = "550px";

            emailLabel.Style["Position"] = "Absolute";
            emailLabel.Style["Top"] = "425px";
            emailLabel.Style["Left"] = "100px";
            emailBox.Style["Position"] = "Absolute";
            emailBox.Style["Top"] = "425px";
            emailBox.Style["Left"] = "250px";
            emailvalidator.Style["Position"] = "Absolute";
            emailvalidator.Style["Top"] = "425px";
            emailvalidator.Style["Left"] = "550px";
            requiredEmail.Style["Position"] = "Absolute";
            requiredEmail.Style["Top"] = "425px";
            requiredEmail.Style["Left"] = "550px";

            countryLabel.Style["Position"] = "Absolute";
            countryLabel.Style["Top"] = "460px";
            countryLabel.Style["Left"] = "100px";
            country.Style["Position"] = "Absolute";
            country.Style["Top"] = "460px";
            country.Style["Left"] = "250px";
            requiredCountry.Style["Position"] = "Absolute";
            requiredCountry.Style["Top"] = "460px";
            requiredCountry.Style["Left"] = "550px";
            notDefaultCountry.Style["Position"] = "Absolute";
            notDefaultCountry.Style["Top"] = "460px";
            notDefaultCountry.Style["Left"] = "550px";
            country.Items.Add(new ListItem("Choose from there", "Choose from there"));
            country.Items.Add(new ListItem("Ukraine", "Ukraine"));
            country.Items.Add(new ListItem("Chech Republic", "Chech Republic"));
            country.SelectedIndexChanged += Country_ChangeSelection;
            country.AutoPostBack = true;

            cityLabel.Style["Position"] = "Absolute";
            cityLabel.Style["Top"] = "495px";
            cityLabel.Style["Left"] = "100px";
            city.Style["Position"] = "Absolute";
            city.Style["Top"] = "495px";
            city.Style["Left"] = "250px";
            requiredCity.Style["Position"] = "Absolute";
            requiredCity.Style["Top"] = "495px";
            requiredCity.Style["Left"] = "550px";
            city.Items.Add(new ListItem("Choose country first", "Choose country first"));
            notDefaultCity.Style["Position"] = "Absolute";
            notDefaultCity.Style["Top"] = "495px";
            notDefaultCity.Style["Left"] = "550px";

            validationSummaryLabel.Style["Position"] = "Absolute";
            validationSummaryLabel.Style["Top"] = "530px";
            validationSummaryLabel.Style["Left"] = "100px";
            summary.Style["Position"] = "Absolute";
            summary.Style["Top"] = "530px";
            summary.Style["Left"] = "250px";

            submitButton.Style["Position"] = "Absolute";
            submitButton.Style["Top"] = "600px";
            submitButton.Style["Left"] = "100px";
            submitButton.Text = "Submit";
            submitButton.Click += submitButton_Click;

            form1.Controls.Add(nickNameBox);
            form1.Controls.Add(nameBox);
            form1.Controls.Add(sirNameBox);
            form1.Controls.Add(birthDateBox);
            form1.Controls.Add(calendar);
            form1.Controls.Add(emailBox);
            form1.Controls.Add(country);
            form1.Controls.Add(city);
            form1.Controls.Add(submitButton);
            form1.Controls.Add(summary);
            form1.Controls.Add(registrationFormLabel);
            form1.Controls.Add(nicknameLabel);
            form1.Controls.Add(nameLabel);
            form1.Controls.Add(sirnameLabel);
            form1.Controls.Add(dateOfBirthLabel);
            form1.Controls.Add(emailLabel);
            form1.Controls.Add(countryLabel);
            form1.Controls.Add(cityLabel);
            form1.Controls.Add(validationSummaryLabel);
            form1.Controls.Add(emailvalidator);
            form1.Controls.Add(requiredEmail);
            form1.Controls.Add(requiredNickname);
            form1.Controls.Add(requiredName);
            form1.Controls.Add(requiredSirname);
            form1.Controls.Add(nameToNick);
            form1.Controls.Add(sirnameToName);
            form1.Controls.Add(dateValidator);
            form1.Controls.Add(requiredDate);
            form1.Controls.Add(requiredCountry);
            form1.Controls.Add(requiredCity);
            form1.Controls.Add(notDefaultCountry);
            form1.Controls.Add(notDefaultCity);
        }
예제 #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()
        {
            if ( !_controlsLoaded )
            {
                Controls.Clear();

                _hfExistingKeyNames = new HtmlInputHidden();
                _hfExistingKeyNames.AddCssClass( "js-existing-key-names" );
                _hfExistingKeyNames.ID = this.ID + "_hfExistingKeyNames";
                Controls.Add( _hfExistingKeyNames );

                _lAttributeActionTitle = new Literal();
                _lAttributeActionTitle.ID = "lAttributeActionTitle";
                Controls.Add( _lAttributeActionTitle );

                _validationSummary = new ValidationSummary();
                _validationSummary.ID = "valiationSummary";
                _validationSummary.CssClass = "alert alert-danger";
                _validationSummary.HeaderText = "Please Correct the Following";
                Controls.Add( _validationSummary );

                _tbName = new RockTextBox();
                _tbName.ID = "tbName";
                _tbName.Label = "Name";
                _tbName.Required = true;
                Controls.Add( _tbName );

                _tbDescription = new RockTextBox();
                _tbDescription.Label = "Description";
                _tbDescription.ID = "tbDescription";
                _tbDescription.TextMode = TextBoxMode.MultiLine;
                _tbDescription.Rows = 3;
                Controls.Add( _tbDescription );

                _cpCategories = new CategoryPicker();
                _cpCategories.ID = "cpCategories_" + this.ID.ToString();
                _cpCategories.Label = "Categories";
                _cpCategories.AllowMultiSelect = true;
                _cpCategories.EntityTypeId = EntityTypeCache.Read( typeof( Rock.Model.Attribute ) ).Id;
                _cpCategories.EntityTypeQualifierColumn = "EntityTypeId";
                Controls.Add( _cpCategories );

                _tbKey = new RockTextBox();
                _tbKey.ID = "tbKey";
                _tbKey.Label = "Key";
                _tbKey.Required = true;
                Controls.Add( _tbKey );

                _cvKey = new CustomValidator();
                _cvKey.ID = "cvKey";
                _cvKey.ControlToValidate = _tbKey.ID;
                _cvKey.ClientValidationFunction = "validateKey";
                _cvKey.ServerValidate += cvKey_ServerValidate;
                _cvKey.Display = ValidatorDisplay.Dynamic;
                _cvKey.CssClass = "validation-error help-inline";
                _cvKey.ErrorMessage = "There is already an existing property with the key value you entered or the key has illegal characters. Please select a different key value and use only letters, numbers and underscores.";
                Controls.Add( _cvKey );

                _tbIconCssClass = new RockTextBox();
                _tbIconCssClass.ID = "_tbIconCssClass";
                _tbIconCssClass.Label = "Icon CSS Class";
                Controls.Add( _tbIconCssClass );

                _cbRequired = new RockCheckBox();
                _cbRequired.ID ="cbRequired";
                _cbRequired.Label = "Required";
                _cbRequired.Text = "Require a value";
                Controls.Add( _cbRequired );

                _cbShowInGrid = new RockCheckBox();
                _cbShowInGrid.ID = "cbShowInGrid";
                _cbShowInGrid.Label = "Show in Grid";
                _cbShowInGrid.Text = "Yes";
                _cbShowInGrid.Help = "If selected, this attribute will be included in a grid.";
                Controls.Add( _cbShowInGrid );

                _cbAllowSearch = new RockCheckBox();
                _cbAllowSearch.ID = "cbAllowSearch";
                _cbAllowSearch.Label = "Allow Search";
                _cbAllowSearch.Text = "Yes";
                _cbAllowSearch.Help = "If selected, this attribute can be search on.";
                _cbAllowSearch.Visible = false;  // Default is to not show this option
                Controls.Add( _cbAllowSearch );

                _ddlFieldType = new RockDropDownList();
                _ddlFieldType.ID = "ddlFieldType";
                _ddlFieldType.Label = "Field Type";
                _ddlFieldType.AutoPostBack = true;
                _ddlFieldType.SelectedIndexChanged += _ddlFieldType_SelectedIndexChanged;
                _ddlFieldType.DataValueField = "Id";
                _ddlFieldType.DataTextField = "Name";
                Controls.Add( _ddlFieldType );

                _phQualifiers = new PlaceHolder();
                _phQualifiers.ID = "phQualifiers";
                _phQualifiers.EnableViewState = false;
                Controls.Add( _phQualifiers );

                _phDefaultValue = new PlaceHolder();
                _phDefaultValue.ID = "phDefaultValue";
                _phDefaultValue.EnableViewState = false;
                Controls.Add( _phDefaultValue );

                _btnSave = new LinkButton();
                _btnSave.ID = "btnSave";
                _btnSave.Text = "OK";
                _btnSave.CssClass = "btn btn-primary";
                _btnSave.Click += btnSave_Click;
                Controls.Add( _btnSave );

                _btnCancel = new LinkButton();
                _btnCancel.ID = "btnCancel";
                _btnCancel.Text = "Cancel";
                _btnCancel.CssClass = "btn btn-link";
                _btnCancel.CausesValidation = false;
                _btnCancel.Click += btnCancel_Click;
                Controls.Add( _btnCancel );

                _controlsLoaded = true;
            }
        }
예제 #3
0
        public virtual void CreateControlHeirarchy()
        {
            HtmlTable table = new HtmlTable();
            table.Build(2, 7);
            Controls.Add(table);

            ErrorValidationSummary = new ValidationSummary
                {
                    ShowSummary = false,
                    ShowMessageBox = true
                };

            ScriptManager sm = ScriptManager.GetCurrent(this.Page);
            sm.Services.Add(new ServiceReference("~/Cathexis.LandingPage.Services.StateServices.asmx"));

            // first table cell 2 wide
            table.Rows[0].Cells.RemoveAt(1);
            table.Rows[0].Cells[0].ColSpan = 2;

            table.Rows[0].Cells[0].Controls.Add(ErrorValidationSummary);

            FirstNameLabel = new Label { Text = "First Name:" };
            table.Rows[1].Cells[0].Controls.Add(FirstNameLabel);

            FirstNameTextBox = new PopulatedTextBox 
                { 
                    ID = "FirstNameTextbox", 
                    RequestVariableName = "f" 
                };
            table.Rows[1].Cells[1].Controls.Add(FirstNameTextBox);

            FirstNameReqValidator = new RequiredFieldValidator
                {
                    ControlToValidate = FirstNameTextBox.ID,
                    ErrorMessage = "'First Name' is not valid.",
                    Text = "*"
                };
            table.Rows[1].Cells[1].Controls.Add(FirstNameReqValidator);

            LastNameLabel = new Label { Text = "Last Name:" };
            table.Rows[2].Cells[0].Controls.Add(LastNameLabel);

            LastNameTextBox = new PopulatedTextBox 
                { 
                    ID = "LastNameTextBox", 
                    RequestVariableName = "l" 
                };
            table.Rows[2].Cells[1].Controls.Add(LastNameTextBox);

            LastNameReqValidator = new RequiredFieldValidator
                {
                    ControlToValidate = LastNameTextBox.ID,
                    ErrorMessage = "'Last Name' is not valid.",
                    Text = "*"
                };
            table.Rows[2].Cells[1].Controls.Add(LastNameReqValidator);

            StateLabel = new Label { Text = "State:" };
            table.Rows[3].Cells[0].Controls.Add(StateLabel);

            StateDropDownList = new DropDownList { ID = "StateDropDownList" };
            table.Rows[3].Cells[1].Controls.Add(StateDropDownList);

            StateReqValidator = new RequiredFieldValidator
            {
                ControlToValidate = StateDropDownList.ID,
                ErrorMessage = "'State' is not valid.",
                Text = "*"
            };
            table.Rows[3].Cells[1].Controls.Add(StateReqValidator);

            CountryLabel = new Label { Text = "Country:" };
            table.Rows[4].Cells[0].Controls.Add(CountryLabel);

            CountryDropDownList = new DropDownList { ID = "CountryDropDownList" };
            table.Rows[4].Cells[1].Controls.Add(CountryDropDownList);

            CountryReqValidator = new RequiredFieldValidator
            {
                ControlToValidate = CountryDropDownList.ID,
                ErrorMessage = "'Country' is not valid.",
                Text = "*"
            };
            table.Rows[4].Cells[1].Controls.Add(CountryReqValidator);

            CountryCascading = new CascadingDropDown
            {
                ID = "CountryCascading",
                TargetControlID = CountryDropDownList.ID,
                Category = "country",
                PromptText = "Select One",
                LoadingText = "Loading...",
                ServiceMethod = "GetCountries",
                ServicePath = "~/Cathexis.LandingPage.Services.StateServices.asmx"
            };

            StateCascading = new CascadingDropDown
            {
                ID = "StateCascading",
                TargetControlID = StateDropDownList.ID,
                Category = "state",
                PromptText = "Select One",
                LoadingText = "Loading...",
                ServiceMethod = "GetDropDownContent",
                ParentControlID = CountryDropDownList.ID,
                ServicePath = "~/Cathexis.LandingPage.Services.StateServices.asmx"
            };

            table.Rows[4].Cells[1].Controls.Add(CountryCascading);
            table.Rows[3].Cells[1].Controls.Add(StateCascading);

            EmailLabel = new Label { Text = "Email:" };
            table.Rows[5].Cells[0].Controls.Add(EmailLabel);

            EmailTextBox = new PopulatedTextBox 
            { 
                ID = "EmailTextBox",
                RequestVariableName = "e"
            };
            table.Rows[5].Cells[1].Controls.Add(EmailTextBox);

            EmailReqValidator = new RequiredFieldValidator
            {
                ControlToValidate = EmailTextBox.ID,
                ErrorMessage = "'Email' is not valid.",
                Text = "*"
            };
            table.Rows[5].Cells[1].Controls.Add(EmailReqValidator);

            PhoneNumberLabel = new Label { Text = "Phone Number" };
            table.Rows[6].Cells[0].Controls.Add(PhoneNumberLabel);

            PhoneNumber = new PhoneNumber();
            table.Rows[6].Cells[1].Controls.Add(PhoneNumber);

        }
예제 #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()
        {
            Controls.Clear();

              pnlValidation = new Panel();
              pnlValidation.Controls.Add(new LiteralControl("&nbsp;"));
              validationSummary = new ValidationSummary();
              validationSummary.DisplayMode = ValidationSummaryDisplayMode.BulletList;
              validationSummary.CssClass = "validationSummary";
              pnlValidation.Controls.Add(validationSummary);

              pnlSuccess = new Panel();
              pnlSuccess.Visible = false;
              pnlSuccess.CssClass = "messagecenterSuccess";
              imgSuccess = new System.Web.UI.WebControls.Image();
              imgSuccess.SkinID = "success";
              lblSuccessMessage = new Label();
              lblSuccessMessage.CssClass = "label";
              pnlSuccess.Controls.Add(new LiteralControl("<div class=\"verticalalign\">"));
              pnlSuccess.Controls.Add(imgSuccess);
              pnlSuccess.Controls.Add(new LiteralControl("&nbsp;"));
              pnlSuccess.Controls.Add(lblSuccessMessage);
              pnlSuccess.Controls.Add(new LiteralControl("</div>"));

              pnlFailure = new Panel();
              pnlFailure.Visible = false;
              pnlFailure.CssClass = "messagecenterFailure";
              imgFailure = new System.Web.UI.WebControls.Image();
              imgFailure.SkinID = "error";
              lblFailureMessage = new Label();
              lblFailureMessage.CssClass = "label";
              pnlFailure.Controls.Add(new LiteralControl("<div class=\"verticalalign\">"));
              pnlFailure.Controls.Add(imgFailure);
              pnlFailure.Controls.Add(new LiteralControl("&nbsp;"));
              pnlFailure.Controls.Add(lblFailureMessage);
              pnlFailure.Controls.Add(new LiteralControl("</div>"));

              pnlInformation = new Panel();
              pnlInformation.Visible = false;
              pnlInformation.CssClass = "messagecenterInformation";
              imgInformation = new System.Web.UI.WebControls.Image();
              imgInformation.SkinID = "information";
              lblInformationMessage = new Label();
              lblInformationMessage.CssClass = "label";
              pnlInformation.Controls.Add(new LiteralControl("<div class=\"verticalalign\">"));
              pnlInformation.Controls.Add(imgInformation);
              pnlInformation.Controls.Add(new LiteralControl("&nbsp;"));
              pnlInformation.Controls.Add(lblInformationMessage);
              pnlInformation.Controls.Add(new LiteralControl("</div>"));

              pnlCritical = new Panel();
              pnlCritical.Visible = false;
              pnlCritical.CssClass = "messagecenterCritical";
              imgCritical = new System.Web.UI.WebControls.Image();
              imgCritical.SkinID = "critical";
              lblCriticalMessage = new Label();
              lblCriticalMessage.CssClass = "label";
              pnlCritical.Controls.Add(new LiteralControl("<div class=\"verticalalign\">"));
              pnlCritical.Controls.Add(imgCritical);
              pnlCritical.Controls.Add(new LiteralControl("&nbsp;"));
              pnlCritical.Controls.Add(lblCriticalMessage);
              pnlCritical.Controls.Add(new LiteralControl("</div>"));

              pnlMessageCenter.Controls.Add(pnlInformation);
              pnlMessageCenter.Controls.Add(pnlSuccess);
              pnlMessageCenter.Controls.Add(pnlFailure);
              pnlMessageCenter.Controls.Add(pnlCritical);
              pnlMessageCenter.Controls.Add(pnlValidation);

              this.Controls.Add(pnlMessageCenter);
              base.CreateChildControls();
        }
예제 #5
0
				/// <summary>
				/// Performs layout of the control.
				/// </summary>
				protected override void CreateChildControls()
				{
					
					// -----------------------------------------------
					// |                    | ---------------------- |
					// | Username:*         | |                    | |
					// |                    | ---------------------- |
					// -----------------------------------------------
					// |                    | ---------------------- |
					// | Old Password:*     | |                    | |
					// |                    | ---------------------- |
					// -----------------------------------------------
					// |                    | ---------------------- |
					// | New Password:*     | |                    | |
					// |                    | ---------------------- |
					// -----------------------------------------------
					// |                    | ---------------------- |
					// | Confirm Password:* | |                    | |
					// |                    | ---------------------- |
					// -----------------------------------------------
					// |                    |         -------------- |
					// |                    |         |   Submit   | |
					// |                    |         -------------- |
					// -----------------------------------------------
					
					// Layout the control.
					Table container = ControlContainer.NewTable(5, 2);
					
					// Row #1
					m_usernameTextBox = new TextBox();
					m_usernameTextBox.ID = "UsernameTextBox";
					m_usernameTextBox.Width = Unit.Parse("150px");
					RequiredFieldValidator usernameValidator = new RequiredFieldValidator();
					usernameValidator.Display = ValidatorDisplay.None;
					usernameValidator.ErrorMessage = "Username is required.";
					usernameValidator.ControlToValidate = m_usernameTextBox.ID;
					container.Rows[0].Cells[0].Text = "Username:*&nbsp;";
					container.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Right;
					container.Rows[0].Cells[1].Controls.Add(m_usernameTextBox);
					container.Rows[0].Cells[1].Controls.Add(usernameValidator);
					
					// Row #2
					m_oldPasswordTextBox = new TextBox();
					m_oldPasswordTextBox.ID = "OldPasswordTextBox";
					m_oldPasswordTextBox.Width = Unit.Parse("150px");
					m_oldPasswordTextBox.TextMode = TextBoxMode.Password;
					RequiredFieldValidator oldPasswordValidator = new RequiredFieldValidator();
					oldPasswordValidator.Display = ValidatorDisplay.None;
					oldPasswordValidator.ErrorMessage = "Old Password is required.";
					oldPasswordValidator.ControlToValidate = m_oldPasswordTextBox.ID;
					container.Rows[1].Cells[0].Text = "Old Password:*&nbsp;";
					container.Rows[1].Cells[0].HorizontalAlign = HorizontalAlign.Right;
					container.Rows[1].Cells[1].Controls.Add(m_oldPasswordTextBox);
					container.Rows[1].Cells[1].Controls.Add(oldPasswordValidator);
					
					// Row #3
					m_newPasswordTextBox = new TextBox();
					m_newPasswordTextBox.ID = "NewPasswordTextBox";
					m_newPasswordTextBox.Width = Unit.Parse("150px");
					m_newPasswordTextBox.TextMode = TextBoxMode.Password;
					RequiredFieldValidator newPasswordValidator = new RequiredFieldValidator();
					newPasswordValidator.Display = ValidatorDisplay.None;
					newPasswordValidator.ErrorMessage = "New Password is required.";
					newPasswordValidator.ControlToValidate = m_newPasswordTextBox.ID;
					container.Rows[2].Cells[0].Text = "New Password:*&nbsp;";
					container.Rows[2].Cells[0].HorizontalAlign = HorizontalAlign.Right;
					container.Rows[2].Cells[1].Controls.Add(m_newPasswordTextBox);
					container.Rows[2].Cells[1].Controls.Add(newPasswordValidator);
					
					// Row #4
					m_confirmPasswordTextBox = new TextBox();
					m_confirmPasswordTextBox.ID = "ConfirmPasswordTextBox";
					m_confirmPasswordTextBox.Width = Unit.Parse("150px");
					m_confirmPasswordTextBox.TextMode = TextBoxMode.Password;
					RequiredFieldValidator confirmPasswordValidator = new RequiredFieldValidator();
					confirmPasswordValidator.Display = ValidatorDisplay.None;
					confirmPasswordValidator.ErrorMessage = "Confirm Password is required.";
					confirmPasswordValidator.ControlToValidate = m_confirmPasswordTextBox.ID;
					container.Rows[3].Cells[0].Text = "Confirm Password:*&nbsp;";
					container.Rows[3].Cells[0].HorizontalAlign = HorizontalAlign.Right;
					container.Rows[3].Cells[1].Controls.Add(m_confirmPasswordTextBox);
					container.Rows[3].Cells[1].Controls.Add(confirmPasswordValidator);
					
					// Row #5
					Button submitButton = new Button();
					submitButton.Text = "Submit";
					submitButton.Click += new System.EventHandler(SubmitButton_Click);
					CompareValidator passwordCompareValidator = new CompareValidator();
					passwordCompareValidator.Display = ValidatorDisplay.None;
					passwordCompareValidator.ErrorMessage = "New Password and Confirm Password must match.";
					passwordCompareValidator.ControlToValidate = m_newPasswordTextBox.ID;
					passwordCompareValidator.ControlToCompare = m_confirmPasswordTextBox.ID;
					ValidationSummary validationSummary = new ValidationSummary();
					validationSummary.ShowSummary = false;
					validationSummary.ShowMessageBox = true;
					container.Rows[4].Cells[0].Controls.Add(passwordCompareValidator);
					container.Rows[4].Cells[0].Controls.Add(validationSummary);
					container.Rows[4].Cells[1].HorizontalAlign = HorizontalAlign.Right;
					container.Rows[4].Cells[1].Controls.Add(submitButton);
					
					this.Controls.Clear();
					this.Controls.Add(container);
					
					// Setup client-side scripts.
					Page.SetFocus(m_usernameTextBox);
					System.Text.StringBuilder with_1 = new StringBuilder();
					with_1.Append("if (typeof(Page_ClientValidate) == \'function\') {");
					with_1.Append("if (Page_ClientValidate() == false) { return false; }}");
					with_1.Append("this.disabled = true;");
					with_1.AppendFormat("document.all.{0}.disabled = true;", submitButton.ClientID);
					with_1.AppendFormat("{0};", Page.ClientScript.GetPostBackEventReference(submitButton, null));
					
					submitButton.OnClientClick = with_1.ToString();
					
					if (m_securityProvider.AuthenticationMode == AuthenticationMode.RSA)
					{
						// In RSA authentication mode the following substitution must take place:
						// Old Password      -> Token
						// New Password      -> New Pin
						// Confirm Password  -> Confirm Pin
						oldPasswordValidator.ErrorMessage = "Token is required.";
						newPasswordValidator.ErrorMessage = "New Pin is required.";
						confirmPasswordValidator.ErrorMessage = "Confirm Pin is required.";
						passwordCompareValidator.ErrorMessage = "New Pin and Confirm Pin must match.";
						container.Rows[1].Cells[0].Text = "Token:*";
						container.Rows[2].Cells[0].Text = "New Pin:*";
						container.Rows[3].Cells[0].Text = "Confirm Pin:*";
						
						if (Page.Session[Login.NewPinVerify] != null)
						{
							// It is verified that the user account is in "new pin" mode and user must create a new pin.
							System.Text.StringBuilder with_2 = new StringBuilder();
							with_2.Append("Note: You are required to create a new pin for your RSA SecurID key. The pin must ");
							with_2.Append("be a 4 to 8 character alpha-numeric string. Please wait for the token on your RSA ");
							with_2.Append("SecurID key to change before proceeding.");
							
							m_container.UpdateMessageText(with_2.ToString(), MessageType.Information);
						}
						else
						{
							// User clicked on the Change Password link, so cannot allow a new pin to be created.
							this.Enabled = false;
							System.Text.StringBuilder with_3 = new StringBuilder();
							with_3.Append("This screen is only active as part of an automated process. To create a new pin, ");
							with_3.Append("you must call the Operations Duty Specialist at 423-751-1700.");
							
							m_container.UpdateMessageText(with_3.ToString(), MessageType.Error);
						}
					}
					
				}
예제 #6
0
        /// <summary>
        /// Initialises the child controls in the upload control.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // Create the controls.
            _validatorFile = new CustomValidator();
            _buttonUpload = new Button();
            _fileUploadData = new FileUpload();
            _validationFileSummary = new ValidationSummary();

            // Set the new controls properties.
            _buttonUpload.ID = "ButtonUpload";
            _buttonUpload.Click += new EventHandler(_buttonUpload_Click);
            _buttonUpload.ValidationGroup = VALIDATION_UPLOAD;
            _fileUploadData.ID = "FileUpload";

            // Set the validators.
            _validatorFile.ID = "ValidatorFile";
            _validationFileSummary.Style.Clear();
            _validationFileSummary.ValidationGroup = VALIDATION_UPLOAD;
            _validatorFile.ValidationGroup = VALIDATION_UPLOAD;
            _validatorFile.ControlToValidate = _fileUploadData.ID;
            _validatorFile.ValidateEmptyText = true;
            _validatorFile.ServerValidate += new ServerValidateEventHandler(_validationFile_ServerValidate);
            _validationFileSummary.ID = "ValidationFileSummary";
            _validationFileSummary.DisplayMode = ValidationSummaryDisplayMode.SingleParagraph;
            _validatorFile.Display = ValidatorDisplay.None;
            _validationFileSummary.EnableClientScript = true;

            // Add the controls to the user control.
            _container.Controls.Add(_validationFileSummary);
            _container.Controls.Add(_fileUploadData);
            _container.Controls.Add(_buttonUpload);
        }
예제 #7
0
        #pragma warning restore 1591

        #endregion

        #endregion

        #region Constructor

        /// <summary>
        /// Constructs a new instance of the <see cref="Redirect"/> control. 
        /// </summary>
        public Redirect()
        {
            CssClass = "redirect";

            _tableBasic = new Table();
            _panelEnabled = new Panel();
            _panelDevicesFile = new Panel();
            _panelFirstRequestOnly = new Panel();
            _panelMobileHomePageUrl = new Panel();
            _panelMobilePagesRegex = new Panel();
            _panelOriginalUrlAsQueryString = new Panel();
            _panelTimeout = new Panel();
            _literalBasic = new Literal();
            _literalLocations = new Literal();
            _textBoxDevicesFile = new TextBox();
            _checkBoxEnabled = new CheckBox();
            _checkBoxFirstRequestOnly = new CheckBox();
            _textBoxMobileHomePageUrl = new TextBox();
            _textBoxMobilePagesRegex = new TextBox();
            _checkBoxOriginalUrlAsQueryString = new CheckBox();
            _textBoxTimeout = new TextBox();
            _buttonReset = new Button();
            _buttonUpdate = new Button();
            _buttonAdd = new Button();
            _validationSummary = new ValidationSummary();
            _customValidatorRegex = new CustomValidator();
            _regularExpressionValidatorDevicesFile = new RegularExpressionValidator();
            _regularExpressionValidatorTimeout = new RegularExpressionValidator();
            _regularExpressionValidatorUrl = new RegularExpressionValidator();
            _panelLocations = new Panel();
            _panelButtons = new Panel();
            _panelBasic = new Panel();
            _panelMessages = new Panel();
            _literalMessage = new Literal();

            _textBoxDevicesFile.ID =
                _regularExpressionValidatorDevicesFile.ControlToValidate = "DevicesFile";
            _textBoxMobileHomePageUrl.ID =
                _regularExpressionValidatorUrl.ControlToValidate = "MobileHomePageUrl";
            _textBoxMobilePagesRegex.ID =
                _customValidatorRegex.ControlToValidate = "MobilePagesRegex";

            _checkBoxFirstRequestOnly.ID = "FirstRequestOnly";
            _checkBoxOriginalUrlAsQueryString.ID = "OriginalUrlAsQueryString";
            _textBoxTimeout.ID = 
                _regularExpressionValidatorTimeout.ControlToValidate = "Timeout";
            _checkBoxEnabled.ID = "Enabled";

            _buttonReset.ID = "Reset";
            _buttonUpdate.ID = "Update";
            _buttonAdd.ID = "Add";

            _buttonUpdate.CausesValidation = true;
            _buttonReset.CausesValidation = _buttonAdd.CausesValidation = false;

            _validationSummary.DisplayMode = ValidationSummaryDisplayMode.List;

            _validationSummary.ValidationGroup =
                _buttonUpdate.ValidationGroup =
                _regularExpressionValidatorDevicesFile.ValidationGroup =
                _regularExpressionValidatorTimeout.ValidationGroup =
                _regularExpressionValidatorUrl.ValidationGroup =
                _customValidatorRegex.ValidationGroup = VALIDATION_GROUP;

            _regularExpressionValidatorDevicesFile.Display =
                _regularExpressionValidatorTimeout.Display =
                _regularExpressionValidatorUrl.Display =
                _customValidatorRegex.Display = ValidatorDisplay.None;

            _regularExpressionValidatorDevicesFile.EnableClientScript =
                _regularExpressionValidatorTimeout.EnableClientScript =
                _regularExpressionValidatorUrl.EnableClientScript = false;

            _regularExpressionValidatorTimeout.ValidationExpression = REGEX_NUMERIC;
            _regularExpressionValidatorDevicesFile.ValidationExpression = REGEX_FILE;
            _regularExpressionValidatorUrl.ValidationExpression = REGEX_URL;

            _buttonUpdate.CausesValidation = true;
        }
 public Validator(ValidationSummary validationSummary, String errorMessage)
 {
     base.ValidationGroup = validationSummary.ValidationGroup;
     base.ErrorMessage = errorMessage;
     base.IsValid = false;
 }
예제 #9
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()
        {
            if ( !_controlsLoaded )
            {
                Controls.Clear();

                _lAttributeActionTitle = new Literal();
                _lAttributeActionTitle.ID = "lAttributeActionTitle";
                Controls.Add( _lAttributeActionTitle );

                _validationSummary = new ValidationSummary();
                _validationSummary.ID = "valiationSummary";
                _validationSummary.CssClass = "alert alert-danger";
                _validationSummary.HeaderText = "Please Correct the Following";
                Controls.Add( _validationSummary ); 
                
                _tbName = new RockTextBox();
                _tbName.ID = "tbName";
                _tbName.Label = "Name";
                _tbName.Required = true;
                Controls.Add( _tbName );

                _tbDescription = new RockTextBox();
                _tbDescription.Label = "Description";
                _tbDescription.ID = "tbDescription";
                _tbDescription.TextMode = TextBoxMode.MultiLine;
                _tbDescription.Rows = 3;
                Controls.Add( _tbDescription );

                _cpCategories = new CategoryPicker();
                _cpCategories.ID = "cpCategories_" + this.ID.ToString();
                _cpCategories.Label = "Categories";
                _cpCategories.AllowMultiSelect = true;
                _cpCategories.EntityTypeId = EntityTypeCache.Read( typeof( Rock.Model.Attribute ) ).Id;
                _cpCategories.EntityTypeQualifierColumn = "EntityTypeId";
                Controls.Add( _cpCategories );

                _tbKey = new RockTextBox();
                _tbKey.ID = "tbKey";
                _tbKey.Label = "Key";
                _tbKey.Required = true;
                Controls.Add( _tbKey );

                _cvKey = new CustomValidator();
                _cvKey.ID = "cvKey";
                _cvKey.ControlToValidate = _tbKey.ID;
                _cvKey.ClientValidationFunction = "validateKey";
                _cvKey.ServerValidate += cvKey_ServerValidate;
                _cvKey.Display = ValidatorDisplay.Dynamic;
                _cvKey.CssClass = "validation-error help-inline";
                _cvKey.ErrorMessage = "There is already an existing property with the key value you entered.  Please select a different key value.";
                Controls.Add( _cvKey );

                _cbRequired = new RockCheckBox();
                _cbRequired.ID ="cbRequired";
                _cbRequired.Label = "Required";
                _cbRequired.Text = "Require a value";
                Controls.Add( _cbRequired );

                _cbShowInGrid = new RockCheckBox();
                _cbShowInGrid.ID = "cbShowInGrid";
                _cbShowInGrid.Label = "Show in Grid";
                _cbShowInGrid.Text = "Yes";
                _cbShowInGrid.Help = "If selected, this attribute will be included in a grid.";
                Controls.Add( _cbShowInGrid );

                _ddlFieldType = new RockDropDownList();
                _ddlFieldType.ID = "ddlFieldType";
                _ddlFieldType.Label = "Field Type";
                _ddlFieldType.AutoPostBack = true;
                _ddlFieldType.SelectedIndexChanged += _ddlFieldType_SelectedIndexChanged;
                Controls.Add( _ddlFieldType );

                if ( !Page.IsPostBack )
                {
                    _ddlFieldType.DataValueField = "Id";
                    _ddlFieldType.DataTextField = "Name";
                    _ddlFieldType.DataSource = new FieldTypeService()
                        .Queryable()
                        .OrderBy( a => a.Name )
                        .Select( a => new { a.Id, a.Name } ).ToList(); ;
                    _ddlFieldType.DataBind();
                }

                _phQualifiers = new PlaceHolder();
                _phQualifiers.ID = "phQualifiers";
                _phQualifiers.EnableViewState = false;
                Controls.Add( _phQualifiers );

                _phDefaultValue = new PlaceHolder();
                _phDefaultValue.ID = "phDefaultValue";
                _phDefaultValue.EnableViewState = false;
                Controls.Add( _phDefaultValue );

                _btnSave = new LinkButton();
                _btnSave.ID = "btnSave";
                _btnSave.Text = "OK";
                _btnSave.CssClass = "btn btn-primary";
                _btnSave.Click += btnSave_Click;
                Controls.Add( _btnSave );

                _btnCancel = new LinkButton();
                _btnCancel.ID = "btnCancel";
                _btnCancel.Text = "Cancel";
                _btnCancel.CssClass = "btn btn-link";
                _btnCancel.CausesValidation = false;
                _btnCancel.Click += btnCancel_Click;
                Controls.Add( _btnCancel );

                _tbName.Attributes["onblur"] = string.Format( "populateAttributeKey('{0}','{1}')", _tbName.ClientID, _tbKey.ClientID );

                _controlsLoaded = true;
            }
        }
예제 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScheduleBuilder"/> class.
        /// </summary>
        public ScheduleBuilderPopupContents()
        {
            // common
            _vsValidation = new ValidationSummary();
            _dpStartDateTime = new DateTimePicker();

            _tbDurationHours = new NumberBox();
            _tbDurationMinutes = new NumberBox();

            _radOneTime = new RockRadioButton();
            _radRecurring = new RockRadioButton();

            _radSpecificDates = new RockRadioButton();
            _radDaily = new RockRadioButton();
            _radWeekly = new RockRadioButton();
            _radMonthly = new RockRadioButton();

            // specific date
            _hfSpecificDateListValues = new HiddenFieldWithClass();
            _hfSpecificDateListValues.CssClass = "js-specific-datelist-values";

            _dpSpecificDate = new DatePicker();

            // daily
            _radDailyEveryXDays = new RockRadioButton();
            _tbDailyEveryXDays = new NumberBox();
            _radDailyEveryWeekday = new RockRadioButton();
            _radDailyEveryWeekendDay = new RockRadioButton();

            // weekly
            _tbWeeklyEveryX = new NumberBox();
            _cbWeeklySunday = new RockCheckBox();
            _cbWeeklyMonday = new RockCheckBox();
            _cbWeeklyTuesday = new RockCheckBox();
            _cbWeeklyWednesday = new RockCheckBox();
            _cbWeeklyThursday = new RockCheckBox();
            _cbWeeklyFriday = new RockCheckBox();
            _cbWeeklySaturday = new RockCheckBox();

            // monthly
            _radMonthlyDayX = new RockRadioButton();
            _tbMonthlyDayX = new NumberBox();
            _tbMonthlyXMonths = new NumberBox();
            _radMonthlyNth = new RockRadioButton();
            _ddlMonthlyNth = new RockDropDownList();
            _ddlMonthlyDayName = new RockDropDownList();

            // end date
            _radEndByNone = new RockRadioButton();
            _radEndByDate = new RockRadioButton();
            _dpEndBy = new DatePicker();
            _radEndByOccurrenceCount = new RockRadioButton();
            _tbEndByOccurrenceCount = new NumberBox();

            // exclusions
            _hfExclusionDateRangeListValues = new HiddenFieldWithClass();
            _hfExclusionDateRangeListValues.CssClass = "js-exclusion-daterange-list-values";
            _dpExclusionDateRange = new DateRangePicker();
        }
예제 #11
0
        protected override void CreateChildControls()
        {
            Controls.Clear();
            _cstvExpirationDate = new CustomValidator();

            _cstvExpirationDate.ID = "cstvExpirationDate";
            _cstvExpirationDate.ControlToValidate = "ddlExpirationMonth";
            _cstvExpirationDate.ServerValidate += new ServerValidateEventHandler(cstvExpirationDate_ServerValidate);

            _litLastName = new Literal();
            _litFirstName = new Literal();



            // creat the controls that will be displayed on the form

            PlaceHolder phGroupControl = new PlaceHolder();
            Controls.Add(phGroupControl);

            HtmlGenericControl div = new HtmlGenericControl("div");
            div.Attributes.Clear();
            div.Attributes.Add("id", "form_margins");
            phGroupControl.Controls.Add(div);

            HtmlTable outerTable = new HtmlTable();
            HtmlTableRow messageRow = new HtmlTableRow();
            HtmlTableCell ccHoldersNameLabelRow = new HtmlTableCell();
            HtmlTableCell ccHolderNameRow = new HtmlTableCell();
            HtmlTableCell ccTypeLabelRow = new HtmlTableCell();
            HtmlTableCell ccTypeRow = new HtmlTableCell();
            HtmlTableCell ccNumberLabelRow = new HtmlTableCell();
            HtmlTableCell ccNumberRow = new HtmlTableCell();
            HtmlTableRow ccNumberMessageRow = new HtmlTableRow();
            HtmlTableCell ccExpiryLabelRow = new HtmlTableCell();
            HtmlTableCell ccExpiryRow = new HtmlTableCell();

            HtmlTableCell ccSecurityLabelRow = new HtmlTableCell();
            HtmlTableCell ccSecurityRow = new HtmlTableCell();

            //HtmlTableRow deliveryOptionRow = new HtmlTableRow();
            //HtmlTableRow ccCaptchaLableRow = new HtmlTableRow();
            //HtmlTableRow ccCaptchaImageRow = new HtmlTableRow();
            //HtmlTableRow ccCaptchaRow = new HtmlTableRow();

            // format the outer table
            outerTable.CellSpacing = 0;
            outerTable.CellPadding = 0;
            outerTable.Border = 0;
            outerTable.Align = "center";
            div.Controls.Add(outerTable);

            // add the rows to the table
            
            outerTable.Rows.Add(messageRow);

            HtmlTableRow _row = new HtmlTableRow();

            _row.Cells.Add(ccHoldersNameLabelRow);
            _row.Cells.Add(ccHolderNameRow);
            outerTable.Rows.Add(_row);

            _row = new HtmlTableRow();
            _row.Cells.Add(ccTypeLabelRow);
            _row.Cells.Add(ccTypeRow);
            outerTable.Rows.Add(_row);

            _row = new HtmlTableRow();
            _row.Cells.Add(ccNumberLabelRow);
            _row.Cells.Add(ccNumberRow);
            outerTable.Rows.Add(_row);

            //outerTable.Rows.Add(ccNumberMessageRow);
            
            _row = new HtmlTableRow();
            _row.Cells.Add(ccExpiryLabelRow);
            _row.Cells.Add(ccExpiryRow);
            outerTable.Rows.Add(_row);

            _row = new HtmlTableRow();
            _row.Cells.Add(ccSecurityLabelRow);
            _row.Cells.Add(ccSecurityRow);
            outerTable.Rows.Add(_row);
            
            //outerTable.Rows.Add(deliveryOptionRow);
            //outerTable.Rows.Add(ccCaptchaImageRow);
            //outerTable.Rows.Add(ccCaptchaLableRow);            
            //outerTable.Rows.Add(ccCaptchaRow);


            HtmlTableCell lblCell = new HtmlTableCell();
            lblCell.ColSpan = 2;
            messageRow.Cells.Add(lblCell);
            _lblMessage = new Label();
            _lblMessage.ID = "lblMessage";
            _lblMessage.ForeColor = Color.Red;
            messageRow.Cells[0].Controls.Add(_lblMessage);

            _summary = new ValidationSummary();
            _summary.ShowMessageBox = true;
            _summary.ShowSummary = false;
            messageRow.Cells[0].Controls.Add(_summary);

            #region Card Holder Full Name
            ccHoldersNameLabelRow.Controls.Add(GetSpan("Cardholder's Name:"));
            #endregion

            #region Card Holder Name Control Row

            _txtCardholderName = new TextBox();
            _txtCardholderName.Attributes.Clear();
            _txtCardholderName.Attributes.Add("class", "form_CardHolder");
            _txtCardholderName.MaxLength = 50;
            _txtCardholderName.ID = "txtCardholderName";


            _rfvRequiredFieldValidator = new RequiredFieldValidator();
            _rfvRequiredFieldValidator.Attributes.Clear();
            _rfvRequiredFieldValidator.Style.Add("visibility", "hidden");
            _rfvRequiredFieldValidator.ID = "rfvRequiredFieldValidator";
            _rfvRequiredFieldValidator.Text = "*";
            _rfvRequiredFieldValidator.ErrorMessage = "'Cardholder Name' is required";
            _rfvRequiredFieldValidator.ControlToValidate = "txtCardholderName";

            ccHolderNameRow.Controls.Add(_txtCardholderName);
            ccHolderNameRow.Controls.Add(_rfvRequiredFieldValidator);
            #endregion

            #region Card holder CC Type

            ccTypeLabelRow.Controls.Add(GetSpan("Card Type:"));

            _ddlCardType = new DropDownList();
            _ddlCardType.Attributes.Clear();
            _ddlCardType.Attributes.Add("class", "form_CardType");
            _ddlCardType.ID = "ddlCardType";

            _rfvCardType = new RequiredFieldValidator();
            _rfvCardType.ID = "rfvCardType";
            _rfvCardType.Text = "*";
            _rfvCardType.ErrorMessage = "'Card Type' is required";
            _rfvCardType.ControlToValidate = "ddlCardType";
            _rfvCardType.InitialValue = "Select card";
            _rfvCardType.EnableClientScript = true;
            _rfvCardType.Display = ValidatorDisplay.Dynamic;
            _rfvCardType.Style.Clear();
            //_rfvCardType.Style.Add("visibility", "hidden");
            //_cstvCardType = new CustomValidator();
            //_cstvCardType.ID = "cstvCardTypes";
            //_cstvCardType.Text = "*";
            //_cstvCardType.ErrorMessage = "'Card Type' is required";

            ccTypeRow.Controls.Add(_ddlCardType);
            ccTypeRow.Controls.Add(_rfvCardType);


            #endregion

            #region Credit Card Number
            ccNumberLabelRow.Controls.Add(GetSpan("Credit Card Number:"));

            _txtCreditCardNumber = new TextBox();
            _txtCreditCardNumber.Attributes.Clear();
            _txtCreditCardNumber.Attributes.Add("class", "form_CreditCardNumber");
            _txtCreditCardNumber.ID = "txtCreditCardNumber";
            _txtCreditCardNumber.MaxLength = 20;


            _rfvCreditCardNumber = new RequiredFieldValidator();
            _rfvCreditCardNumber.Text = "*";
            _rfvCreditCardNumber.ID = "rfvCreditCardNumber";
            _rfvCreditCardNumber.ControlToValidate = "txtCreditCardNumber";
            _rfvCreditCardNumber.ErrorMessage = "'Credit Card Number' is required";

            _revCreditCardNumber = new RegularExpressionValidator();
            _revCreditCardNumber.Text = "*";
            _revCreditCardNumber.ID = "revCreditCardNumber";
            _revCreditCardNumber.ControlToValidate = "txtCreditCardNumber";
            _revCreditCardNumber.ErrorMessage = "'Credit Card Number' is invalid";
            _revCreditCardNumber.ValidationExpression = RegularExpressions.ValidCreditCard;

            ccNumberRow.Controls.Add(_txtCreditCardNumber);
            ccNumberRow.Controls.Add(_rfvCreditCardNumber);
            ccNumberRow.Controls.Add(_revCreditCardNumber);

            HtmlGenericControl ccMessageSpan = new HtmlGenericControl("span");
            ccMessageSpan.Attributes.Add("class", "form_text");
            ccMessageSpan.InnerHtml = "<i>Please do not use spaces or hyphens</i>";
            ccNumberMessageRow.Cells.Add(new HtmlTableCell());
            ccNumberMessageRow.Cells[0].Controls.Add(ccMessageSpan);


            #endregion

            #region Expriy Date
            ccExpiryLabelRow.Controls.Add(GetSpan("Expiration Date:"));

            _ddlExpirationMonth = new DropDownList();
            _ddlExpirationMonth.Attributes.Clear();
            _ddlExpirationMonth.Attributes.Add("class", "form_Expiration1");
            _ddlExpirationMonth.ID = "ddlExpirationMonth";

            _ddlExpirationYear = new DropDownList();
            _ddlExpirationYear.Attributes.Clear();
            _ddlExpirationYear.Attributes.Add("class", "form_Expiration2");
            _ddlExpirationYear.ID = "ddlExpirationYear";

            ccExpiryRow.Controls.Add(_ddlExpirationMonth);
            ccExpiryRow.Controls.Add(_ddlExpirationYear);
            ccExpiryRow.Controls.Add(_cstvExpirationDate);

            #endregion

            #region security code

            ccSecurityLabelRow.Controls.Add(GetSpan("CVV/Security Code:"));

            _txtSecurityCode = new TextBox();
            _txtSecurityCode.Attributes.Clear();
            _txtSecurityCode.Attributes.Add("class", "form_SecurityCode");
            _txtSecurityCode.ID = "txtSecurityCode";

            _rfvSecurityCode = new RequiredFieldValidator();
            _rfvSecurityCode.ID = "rfvSecurityCode";
            _rfvSecurityCode.Text = "*";
            _rfvSecurityCode.ErrorMessage = "'Security Code' is required";
            _rfvSecurityCode.ControlToValidate = "txtSecurityCode";

            ccSecurityRow.Controls.Add(_txtSecurityCode);
            ccSecurityRow.Controls.Add(_rfvSecurityCode);

            #endregion

            #region Delivery Option

            //if (!string.IsNullOrEmpty(OfferController.OfferSettings.Price))
            //{
            //    deliveryOptionRow.Cells.Add(new HtmlTableCell());
            //    deliveryOptionRow.Cells[0].Controls.Add(GetSpan("Delivery Option:"));

            //    _radStandard = new RadioButton();
            //    _radStandard.Text = this.StandardDeliveryText;
            //    _radStandard.GroupName = "Delivery";
            //    _radStandard.ID = "radStandard";
            //    _radStandard.Checked = true;

            //    _radDownload = new RadioButton();
            //    _radDownload.Text = this.DownloadOptionText;
            //    _radDownload.GroupName = "Delivery";
            //    _radDownload.ID = "radDownload";

            //    deliveryOptionRow.Cells[0].Controls.Add(new LiteralControl("<br/>"));
            //    deliveryOptionRow.Cells[0].Controls.Add(_radStandard);
            //    deliveryOptionRow.Cells[0].Controls.Add(new LiteralControl("<br/>"));
            //    deliveryOptionRow.Cells[0].Controls.Add(_radDownload);
            //}

            #endregion

            #region Captcha

            //ccCaptchaLableRow.Cells.Add(new HtmlTableCell());
            //ccCaptchaLableRow.Cells[0].Controls.Add(GetSpan("To ensure your security and the accuracy of this order, please enter the text shown in the image above."));

            //_imgCaptcha = new System.Web.UI.WebControls.Image();
            //_imgCaptcha.Attributes.Clear();
            //_imgCaptcha.Attributes.Add("class", "form_Image");
            //_imgCaptcha.ID = "imgCaptcha";
            //_imgCaptcha.ImageUrl = "~/Captcha.ashx";

            //ccCaptchaImageRow.Cells.Add(new HtmlTableCell());
            //ccCaptchaImageRow.Cells[0].Controls.Add(_imgCaptcha);

            //_txtCaptcha = new TextBox();
            //_txtCaptcha.Attributes.Clear();
            //_txtCaptcha.Attributes.Add("class", "form_Captcha");
            //_txtCaptcha.ID = "txtCaptcha";

            //ccCaptchaRow.Cells.Add(new HtmlTableCell());
            //ccCaptchaRow.Cells[0].Controls.Add(_txtCaptcha);


            #endregion
        }
예제 #12
0
파일: Login.cs 프로젝트: avs009/gsf
				/// <summary>
				/// Performs layout of the control.
				/// </summary>
				protected override void CreateChildControls()
				{
					
					// -----------------------------------------
					// |              | ---------------------- |
					// | Username:*   | |                    | |
					// |              | ---------------------- |
					// -----------------------------------------
					// |              | ---------------------- |
					// | Password:*   | |                    | |
					// |              | ---------------------- |
					// -----------------------------------------
					// |              |         -------------- |
					// |              |         |   Submit   | |
					// |              |         -------------- |
					// -----------------------------------------
					
					// Layout the control.
					Table container = ControlContainer.NewTable(3, 2);
					
					// Row #1
					m_usernameTextBox = new TextBox();
					m_usernameTextBox.ID = "UsernameTextBox";
					m_usernameTextBox.Width = Unit.Parse("150px");
					RequiredFieldValidator usernameValidator = new RequiredFieldValidator();
					usernameValidator.Display = ValidatorDisplay.None;
					usernameValidator.ErrorMessage = "Username is required.";
					usernameValidator.ControlToValidate = m_usernameTextBox.ID;
					container.Rows[0].Cells[0].Text = "Username:*&nbsp;";
					container.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Right;
					container.Rows[0].Cells[1].Controls.Add(m_usernameTextBox);
					container.Rows[0].Cells[1].Controls.Add(usernameValidator);
					
					// Row #2
					m_passwordTextBox = new TextBox();
					m_passwordTextBox.ID = "PasswordTextBox";
					m_passwordTextBox.Width = Unit.Parse("150px");
					m_passwordTextBox.TextMode = TextBoxMode.Password;
					RequiredFieldValidator passwordValidator = new RequiredFieldValidator();
					passwordValidator.Display = ValidatorDisplay.None;
					passwordValidator.ErrorMessage = "Password is required.";
					passwordValidator.ControlToValidate = m_passwordTextBox.ID;
					container.Rows[1].Cells[0].Text = "Password:*&nbsp;";
					container.Rows[1].Cells[0].HorizontalAlign = HorizontalAlign.Right;
					container.Rows[1].Cells[1].Controls.Add(m_passwordTextBox);
					container.Rows[1].Cells[1].Controls.Add(passwordValidator);
					
					// Row #3
					Button submitButton = new Button();
					submitButton.Text = "Submit";
					submitButton.Click += new System.EventHandler(SubmitButton_Click);
					ValidationSummary validationSummary = new ValidationSummary();
					validationSummary.ShowSummary = false;
					validationSummary.ShowMessageBox = true;
					container.Rows[2].Cells[0].Controls.Add(validationSummary);
					container.Rows[2].Cells[1].HorizontalAlign = HorizontalAlign.Right;
					container.Rows[2].Cells[1].Controls.Add(submitButton);
					
					this.Controls.Clear();
					this.Controls.Add(container);
					
					// Setup client-side scripts.
					Page.SetFocus(m_usernameTextBox);
					System.Text.StringBuilder with_1 = new StringBuilder();
					with_1.Append("if (typeof(Page_ClientValidate) == \'function\') {");
					with_1.Append("if (Page_ClientValidate() == false) { return false; }}");
					with_1.Append("this.disabled = true;");
					with_1.AppendFormat("document.all.{0}.disabled = true;", submitButton.ClientID);
					with_1.AppendFormat("{0};", Page.ClientScript.GetPostBackEventReference(submitButton, null));
					
					submitButton.OnClientClick = with_1.ToString();
					
					if (m_securityProvider.AuthenticationMode == AuthenticationMode.RSA)
					{
						// If RSA authentication is used, we'll provided a hint about the username and password, as there
						// may be some confussion as to what makes-up the password when a web page is secured using RSA.
						System.Text.StringBuilder with_2 = new StringBuilder();
						with_2.Append("Note: This web page is secured using RSA Security. The Username is the ID that was ");
						with_2.Append("provided to you when you received your RSA SecurID key, and the Password consists ");
						with_2.Append("of your pin followed by the token currently being displayed on your RSA SecurID key.");
						
						m_container.UpdateMessageText(with_2.ToString(), MessageType.Information);
					}
					
				}
예제 #13
0
        /// <summary>
        /// This is the main method where we generate the from using refelection
        /// this method requied to set the follwoing properties <typeparamref name="ObjectInfo"/> and <typeparamref name="Mode"/>
        /// </summary>
        public void Generate()
        {
            //firing the event
            OnPreFormGeneate(this, EventArgs.Empty);
            table = new Table();
            /* Beging adding heading to the form*/
            object[] classAttributes = DataSource.GetType().GetCustomAttributes(false);
            //quering for the caption attribute
            var cAtt = (from ca in classAttributes where ca.GetType() == typeof(CaptionAttribute) select ca).SingleOrDefault();

            string className = "";
            if (cAtt != null)
                className = cAtt.GetType().GetField("Text").GetValue(cAtt).ToString();
            else
                className = DataSource.GetType().Name;

            // code for header  style

            Table htable = new Table();
            htable.CellPadding = 0;
            htable.CellSpacing = 0;
            htable.Width = Unit.Parse("100%");
            htable.BorderWidth = Unit.Parse("0px");
            TableRow hRow = new TableRow();
            TableCell hCell = new TableCell();
            LiteralControl ltTitle = new LiteralControl("<nobr>" + className + "</nobr>");
            hCell.CssClass = TitleCssClass;
            hCell.Wrap = true;
            hCell.Controls.Add(ltTitle);
            hRow.Cells.Add(hCell);

            TableCell cellh1 = new TableCell();
            cellh1.CssClass = "head1";
            hRow.Cells.Add(cellh1);

            TableCell cellh2 = new TableCell();
            cellh2.CssClass = "head2";
            hRow.Cells.Add(cellh2);

            TableCell cellh3 = new TableCell();
            cellh3.CssClass = "head3";
            hRow.Cells.Add(cellh3);
            htable.Rows.Add(hRow);

            TableCell headerCell = new TableCell();
            //headerCell.ColumnSpan = 2;
            headerCell.Controls.Add(htable);
            TableRow headerRow = new TableRow();
            headerRow.Cells.Add(headerCell);
            //table.Rows.Add(headerRow);

            // * finish code for header style

            /*finish adding heading to the form*/

            /* Adding Result message lable*/
            TableCell rscell = new TableCell();
            rscell.HorizontalAlign = HorizontalAlign.Right;
            rscell.ColumnSpan = 2;
            Label rsLable = new Label();

            rsLable.ID = "lblRsMessage";
            rsLable.Visible = false;
            rscell.Controls.Add(rsLable);

            TableRow rsrow = new TableRow();
            rsrow.Cells.Add(rscell);

            table.Rows.Add(rsrow);
            /* Finish Result message lable*/

            /* Adding Validation Summary*/
            TableCell vscell = new TableCell();
            ValidationSummary validationSummary = new ValidationSummary();
            vscell.Controls.Add(validationSummary);

            TableRow vsrow = new TableRow();
            vsrow.Cells.Add(vscell);

            //table.Rows.Add(vsrow);
            /* Finish Validation Summary*/

            //getting the properties of the object passed in ObjectInfo Property
            PropertyInfo[] properties = DataSource.GetType().GetProperties();
            foreach (PropertyInfo pi in properties)
            {
                //checking for Hidden Attribute to hide the property from generation
                object[] hiddenAttribues = pi.GetCustomAttributes(typeof(HiddenAttribute), false);
                if (hiddenAttribues.Length != 0)
                {
                    HiddenAttribute hAtt = (HiddenAttribute)hiddenAttribues[0];//only first one
                    bool formHidden = (bool)hAtt.GetType().GetField("Form").GetValue(hAtt);
                    if (formHidden)
                        continue;
                }

                /* begin handling cascad dropdowns */
                stkProperties = new Stack<PropertyInfo>();
                GetCascadLookups(pi);
                if (stkProperties.Count != 0)
                {
                    while (stkProperties.Count != 0)
                    //for (int i = 0; i <= stkProperties.Count; i++)
                    {
                        PropertyInfo lpi = stkProperties.Pop();
                        AddFieldToMainTable(lpi);
                    }

                }
                /* End handling cascad dropdowns */

                AddFieldToMainTable(pi);

            }
            /*Begin Adding Commands to the Geneated Form */
            TableRow CommandRow = new TableRow();
            TableCell CommandCell = new TableCell();
            //add blank cell to right form
            TableCell BlankCell = new TableCell();
            CommandRow.Cells.Add(BlankCell);

            //Buttons Generation in a function
            CommandCell.Controls.Add(GetButtons());

            CommandRow.Cells.Add(CommandCell);

            table.Rows.Add(CommandRow);

            this.Controls.Clear();
            /*Finish Adding Commands to the Geneated Form */
            //firing the post genreation event

            OnPostFormGeneate(table, EventArgs.Empty);

            //* split controls in tow tables header and container for style

            Table allTables = new Table();
            allTables.Rows.Add(headerRow);
            allTables.CellSpacing = 0;
            allTables.Width = Unit.Parse("100%");

            TableCell contentCell = new TableCell();
            table.CssClass = "border_td_content";
            table.Width = Unit.Parse("100%");
            contentCell.Controls.Add(table);
            TableRow contentRow = new TableRow();
            contentRow.Cells.Add(contentCell);
            allTables.Rows.Add(contentRow);

            //*finish split controls in tow tables header and container for style

            this.Controls.Add(allTables);
        }
예제 #14
0
        /// <summary>
        /// Creates control hierarchy
        /// </summary>
        protected void CreateControlHierarchy()
        {
            contactFormTable = new Table();
            contactFormTable.CssClass = "contactForm";

            if (DesignMode)
            {
                contactFormTable.BorderWidth = 1;
                contactFormTable.BorderStyle = BorderStyle.Dotted;
            }

            #region "  Control Init  "

            InitializeLabel(ref lblSendError, "Failed to send message");
            lblSendError.CssClass = "sendError";
            lblSendError.Visible = false;

            InitializeLabel(ref lblToName, "To Name: ");
            InitializeLabel(ref lblToAddress, "To Address: ");
            InitializeLabel(ref lblFromName, "From Name: ");
            InitializeLabel(ref lblFromAddress, "From Address: ");
            InitializeLabel(ref lblSubject, "Subject: ");
            InitializeLabel(ref lblMessage, "Message: ");

            InitializeTextBox(ref tbToName, "tbToName", UniqueID);
            InitializeTextBox(ref tbToAddress, "tbToAddress", UniqueID);
            InitializeTextBox(ref tbFromName, "tbFromName", UniqueID);
            InitializeTextBox(ref tbFromAddress, "tbFromAddress", UniqueID);
            InitializeTextBox(ref tbSubject, "tbSubject", UniqueID);
            InitializeTextBox(ref tbMessage, "tbMessage", UniqueID);

            if (btnSend == null)
            {
                btnSend = new Button();
                btnSend.Text = "Send";
            }
            btnSend.CssClass = "btn";
            btnSend.ValidationGroup = UniqueID;

            #endregion

            #region "  Validation Code  "

            validationSummary = new ValidationSummary();
            validationSummary.ValidationGroup = UniqueID;

            InitializeRequiredFieldValidator(ref rfvToName, "rfvToName", tbToAddress.ID,
                UniqueID, "*", "To name is required", true, ValidatorDisplay.Dynamic);

            InitializeRequiredFieldValidator(ref rfvToAddress, "rfvToAddress", tbToAddress.ID,
                UniqueID, "*", "To address is required", true, ValidatorDisplay.Dynamic);

            InitializeRegularExpressionValidator(ref revToAddress, "revToAddress", tbToAddress.ID, EmailExpression,
                UniqueID, "*", "To address must be an email address", false, ValidatorDisplay.Static);

            InitializeRequiredFieldValidator(ref rfvFromName, "rfvFromName", tbFromName.ID,
                UniqueID, "*", "From name is required", true, ValidatorDisplay.Dynamic);

            InitializeRequiredFieldValidator(ref rfvFromAddress, "rfvFromAddress", tbFromAddress.ID,
                UniqueID, "*", "From address is required", true, ValidatorDisplay.Dynamic);

            InitializeRegularExpressionValidator(ref revFromAddress, "revFromAddress", tbFromAddress.ID, EmailExpression,
                UniqueID, "*", "From address must be an email address", false, ValidatorDisplay.Static);

            InitializeRequiredFieldValidator(ref rfvSubject, "rfvSubject", tbSubject.ID,
                UniqueID, "*", "Subject is required", true, ValidatorDisplay.Dynamic);

            InitializeRequiredFieldValidator(ref rfvMessage, "rfvMessage", tbMessage.ID,
                UniqueID, "*", "Message is required", true, ValidatorDisplay.Dynamic);

            validators = new List<IValidator>();
            validators.Add(rfvToName);
            validators.Add(rfvToAddress);
            validators.Add(revToAddress);
            validators.Add(rfvFromName);
            validators.Add(rfvFromAddress);
            validators.Add(revFromAddress);
            validators.Add(rfvSubject);
            validators.Add(rfvMessage);

            #endregion

            #region "  Template Code  "

            if (GreetingTemplate != null)
            {
                greetingTemplateContainer = new GreetingTemplateContainer(this);
                GreetingTemplate.InstantiateIn(greetingTemplateContainer);
                InitalizerPlaceHolder(ref greetingPlaceHolder);
                greetingPlaceHolder.Controls.Add(greetingTemplateContainer);
            }

            if (ThankYouTemplate != null)
            {
                thankYouTemplateContainer = new ThankYouTemplateContainer(this);
                ThankYouTemplate.InstantiateIn(thankYouTemplateContainer);
                InitalizerPlaceHolder(ref thankYouPlaceHolder);
                thankYouPlaceHolder.Controls.Add(thankYouTemplateContainer);
            }

            #endregion

            #region "  Table Code  "

            // To name row
            toNameRow = CreateTableRow(lblToName, tbToName, rfvToName);
            contactFormTable.Rows.Add(toNameRow);

            // To address row
            toAddressRow = CreateTableRow(lblToAddress, tbToAddress,
                rfvToAddress, revToAddress);
            toAddressRow.ID = "toAddressRow";
            contactFormTable.Rows.Add(toAddressRow);

            // From name row
            fromNameRow = CreateTableRow(lblFromName, tbFromName, rfvFromName);
            contactFormTable.Rows.Add(fromNameRow);

            // From address row
            fromAddressRow = CreateTableRow(lblFromAddress, tbFromAddress,
                rfvFromAddress, revFromAddress);
            contactFormTable.Rows.Add(fromAddressRow);

            // Subject row
            TableRow subjectRow = CreateTableRow(lblSubject, tbSubject, rfvSubject);
            contactFormTable.Rows.Add(subjectRow);

            // Message header row
            TableRow messageLabelRow = new TableRow();
            TableCell messageLabelCell = new TableCell();
            messageLabelCell.ColumnSpan = 2;
            messageLabelCell.CssClass = "lblTop";
            messageLabelCell.Controls.Add(lblMessage);
            messageLabelCell.Controls.Add(rfvMessage);
            messageLabelRow.Cells.Add(messageLabelCell);
            contactFormTable.Rows.Add(messageLabelRow);

            // Message text row
            TableRow messageTextRow = new TableRow();
            TableCell messageTextCell = new TableCell();
            messageTextCell.ColumnSpan = 2;
            messageTextCell.CssClass = "ta";
            tbMessage.CssClass = "ta";
            tbMessage.Rows = 3;
            tbMessage.TextMode = TextBoxMode.MultiLine;
            messageTextCell.Controls.Add(tbMessage);
            messageTextRow.Cells.Add(messageTextCell);
            contactFormTable.Rows.Add(messageTextRow);

            // Button row
            btnSend.Click += new EventHandler(btnSend_Click);
            TableRow buttonRow = new TableRow();
            TableCell buttonCell = new TableCell();
            buttonCell.ColumnSpan = 2;
            buttonCell.CssClass = "btn";
            buttonCell.Controls.Add(btnSend);
            buttonRow.Cells.Add(buttonCell);
            contactFormTable.Rows.Add(buttonRow);

            #endregion

            if (!DesignMode)
            {
                _displayMode = ContactFormDisplayMode.Greeting;
            }

            // Add controls to hierarchy
            if (greetingPlaceHolder != null)
            {
                Controls.Add(greetingPlaceHolder);
            }
            Controls.Add(lblSendError);
            Controls.Add(validationSummary);
            Controls.Add(contactFormTable);
            if (thankYouPlaceHolder != null)
            {
                Controls.Add(thankYouPlaceHolder);
            }

            SetVisiblity();
            ChangeDisplayMode();

            ChildControlsCreated = true;
        }
예제 #15
0
파일: EditView.cs 프로젝트: Marceli/Roberta
 private void AddErrorSummary()
 {
     Controls.Add(new LiteralControl(string.Format("<tr><td colspan=\"{0}\" align=\"center\">\r\n\t", 2*Columns)));
     ValidationSummary summary = new ValidationSummary();
     summary.ID = ID + "_Errors";
     summary.ValidationGroup = ID;
     summary.CssClass = cssWarning;
     Controls.Add(summary);
     Controls.Add(new LiteralControl("</td></tr>\r\n"));
 }
예제 #16
0
        void CreateWebControlsForPanel(MPanel activePanel, System.Web.UI.WebControls.Panel containerPanel)
        {
            List<BaseValidator> validators = new List<BaseValidator>();

            validationSummary = new ValidationSummary();
            validationSummary.BorderWidth = 0;
            MainPanel.Controls.Add(validationSummary);

            // no data in active panel => have to fill it
            if (!Page.IsPostBack || noSessionForActPanel)
            {
                if (CE.GlobalState == GlobalState.Architect)
                {
                    foreach (IField field in activePanel.fields) {
                        field.InventData();
                    }
                    foreach (_min.Models.Control c in activePanel.controls)
                    {
                        c.InventData();
                    }
                }
                else
                {
                    mm.WebDriver.FillPanelFKOptions(activePanel);
                    if (activePanel.PK != null || activePanel.type != PanelTypes.Editable)
                        try
                        {
                            mm.WebDriver.FillPanel(activePanel);
                        }
                        catch (WebDriverDataModificationException me) {
                            // the row with the corresponding PK had been deleted in the meantime
                            _min.Common.ValidationError.Display(me.Message, Page);
                        }
                }

            }

            if (activePanel.type == PanelTypes.Editable)
            {
                // create a table with fields and captions tod display
                Table tbl = new Table();
                tbl.CssClass = "formTbl";

                foreach (IField f in activePanel.fields)
                {
                    if (activePanel.PK == null && !Page.IsPostBack) f.Data = null;
                    //if (f.type == FieldTypes.Holder) throw new NotImplementedException("Holder fields not yet supported in UI");
                    TableRow row = new TableRow();
                    TableCell captionCell = new TableCell();
                    Label caption = new Label();
                    caption.Text = f.Caption;
                    captionCell.Controls.Add(caption);
                    row.Cells.Add(captionCell);

                    TableCell fieldCell = new TableCell();
                    System.Web.UI.WebControls.WebControl c = f.MyControl;
                    validators.AddRange(f.GetValidators());

                    foreach (BaseValidator v in validators)
                    {
                        this.Form.Controls.Add(v);
                    }

                    fieldCell.Controls.Add(c);
                    row.Cells.Add(fieldCell);
                    tbl.Rows.Add(row);
                }

                MainPanel.Controls.Add(tbl);
            }

            // add the Constrols
            foreach (_min.Models.Control control in activePanel.controls)
            {
                if (control is TreeControl)
                {
                    ((TreeControl)control).ToUControl(containerPanel, navigator.TreeHandler);
                }
                else if (control is NavTableControl)
                {        // it is a mere gridview of a summary panel
                    NavTableControl ntc = (NavTableControl)control;
                    ntc.ToUControl(containerPanel, new GridViewCommandEventHandler(GridCommandEventHandler), GridView_PageIndexChanging, GridView_Sorting);

                }
                else    // a simple Button or alike
                {
                    if ((control.action == UserAction.Update || control.action == UserAction.Delete) && Page.Request.QueryString.Count == 0)
                        continue;
                    control.ToUControl(containerPanel, (CommandEventHandler)UserActionCommandHandler);
                }
                // not GridViewCommandEventHandler
            }

            foreach (BaseValidator validator in validators)
            {
                MainPanel.Controls.Add(validator);
            }

            // set the webcontrols from the stored value (initially null)
            foreach (_min.Interfaces.IField f in activePanel.fields)
            {
                f.FillData();
            }
        }
예제 #17
0
        /// <summary>
        /// Load the controls which will form the user interface.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // Set the literal control.
            _literalUpload = new Literal();
            _literalInstructions = new Literal();

            // Create the required controls.
            _textBoxLicenceKey = new TextBox();
            _buttonActivate = new Button();
            _buttonRefresh = new Button();
            _validatorRequired = new RequiredFieldValidator();
            _validatorRegEx = new RegularExpressionValidator();
            _validationLicenceSummary = new ValidationSummary();
            _literalResult = new Literal();

            // Set the new controls properties.
            _buttonActivate.ID = "ButtonActivate";
            _buttonActivate.Click += new EventHandler(_buttonActivate_Click);
            _buttonActivate.ValidationGroup = VALIDATION_LICENCE;
            _buttonRefresh.ID = "ButtonRefresh";
            _buttonRefresh.Click += new EventHandler(_buttonActivate_Click);
            _buttonRefresh.Visible = false;
            _textBoxLicenceKey.ID = "TextBoxLicenceKey";
            _textBoxLicenceKey.ValidationGroup = VALIDATION_LICENCE;
                        
            // Set the validators.
            _validatorRequired.ID = "ValidatorRequired";
            _validatorRegEx.ID = "ValidatorRegEx";
            _validationLicenceSummary.ID = "ValidationLicenceSummary";
            _validatorRequired.ControlToValidate = _validatorRegEx.ControlToValidate = _textBoxLicenceKey.ID;
            _validatorRegEx.ValidationGroup = _validatorRequired.ValidationGroup = VALIDATION_LICENCE;
            _validatorRegEx.ValidationExpression = FiftyOne.Foundation.Mobile.Detection.Constants.LicenceKeyValidationRegex;
            _validationLicenceSummary.DisplayMode = ValidationSummaryDisplayMode.SingleParagraph;
            _validationLicenceSummary.Style.Clear();
            _validationLicenceSummary.ValidationGroup = VALIDATION_LICENCE;
            _validatorRequired.Display = _validatorRegEx.Display = ValidatorDisplay.None;
            _validatorRegEx.EnableClientScript = _validatorRequired.EnableClientScript =
                _validationLicenceSummary.EnableClientScript = true;

            // Set the child controls.
            _upload.FooterEnabled = false;
            _upload.LogoEnabled = false;
            _upload.UploadComplete += new UploadEventHandler(_upload_UploadComplete);
            _shareUsage.LogoEnabled = false;
            _shareUsage.FooterEnabled = false;
            _shareUsage.ShareUsageChanged += new ShareUsageChangedEventHandler(_shareUsage_ShareUsageChanged);

            // Add the controls to the user control.
            _container.Controls.Add(_literalResult);
            _container.Controls.Add(_validationLicenceSummary);
            
            _container.Controls.Add(_literalInstructions);
            
            if (IsPaidFor == false)
            {
                _container.Controls.Add(_validatorRequired);
                _container.Controls.Add(_validatorRegEx);
                _container.Controls.Add(_textBoxLicenceKey);
                _container.Controls.Add(_buttonActivate);
                _container.Controls.Add(_buttonRefresh);
                _container.Controls.Add(_literalUpload);
                _container.Controls.Add(_upload);
            }

            _container.Controls.Add(_shareUsage);
        }