public void InstantiateIn (Control container)
			{
				Table table = new Table ();
				table.CellPadding = 0;

				// Row #0
				table.Controls.Add (
					CreateRow (new LiteralControl (_owner.ChangePasswordTitleText),
					null, null, _owner.TitleTextStyle, null));

				// Row #1
				if (_owner.InstructionText.Length > 0) {
					table.Controls.Add (
						CreateRow (new LiteralControl (_owner.InstructionText),
						null, null, _owner.InstructionTextStyle, null));
				}

				// Row #2
				if (_owner.DisplayUserName) {
					TextBox UserName = new TextBox ();
					UserName.ID = "UserName";
					UserName.Text = _owner.UserName;
					UserName.ApplyStyle (_owner.TextBoxStyle);

					Label UserNameLabel = new Label ();
					UserNameLabel.ID = "UserNameLabel";
					UserNameLabel.AssociatedControlID = "UserName";
					UserNameLabel.Text = _owner.UserNameLabelText;

					RequiredFieldValidator UserNameRequired = new RequiredFieldValidator ();
					UserNameRequired.ID = "UserNameRequired";
					UserNameRequired.ControlToValidate = "UserName";
					UserNameRequired.ErrorMessage = _owner.UserNameRequiredErrorMessage;
					UserNameRequired.ToolTip = _owner.UserNameRequiredErrorMessage;
					UserNameRequired.Text = "*";
					UserNameRequired.ValidationGroup = _owner.ID;
					UserNameRequired.ApplyStyle (_owner.ValidatorTextStyle);

					table.Controls.Add (CreateRow (UserNameLabel, UserName, UserNameRequired, _owner.LabelStyle, null));
				}

				// Row #3
				TextBox CurrentPassword = new TextBox ();
				CurrentPassword.ID = "CurrentPassword";
				CurrentPassword.TextMode = TextBoxMode.Password;
				CurrentPassword.ApplyStyle (_owner.TextBoxStyle);

				Label CurrentPasswordLabel = new Label ();
				CurrentPasswordLabel.ID = "CurrentPasswordLabel";
				CurrentPasswordLabel.AssociatedControlID = "CurrentPasswordLabel";
				CurrentPasswordLabel.Text = _owner.PasswordLabelText;

				RequiredFieldValidator CurrentPasswordRequired = new RequiredFieldValidator ();
				CurrentPasswordRequired.ID = "CurrentPasswordRequired";
				CurrentPasswordRequired.ControlToValidate = "CurrentPassword";
				CurrentPasswordRequired.ErrorMessage = _owner.PasswordRequiredErrorMessage;
				CurrentPasswordRequired.ToolTip = _owner.PasswordRequiredErrorMessage;
				CurrentPasswordRequired.Text = "*";
				CurrentPasswordRequired.ValidationGroup = _owner.ID;
				CurrentPasswordRequired.ApplyStyle (_owner.ValidatorTextStyle);

				table.Controls.Add (CreateRow (CurrentPasswordLabel, CurrentPassword, CurrentPasswordRequired, _owner.LabelStyle, null));

				// Row #4
				TextBox NewPassword = new TextBox ();
				NewPassword.ID = "NewPassword";
				NewPassword.TextMode = TextBoxMode.Password;
				NewPassword.ApplyStyle (_owner.TextBoxStyle);

				Label NewPasswordLabel = new Label ();
				NewPasswordLabel.ID = "NewPasswordLabel";
				NewPasswordLabel.AssociatedControlID = "NewPassword";
				NewPasswordLabel.Text = _owner.NewPasswordLabelText;

				RequiredFieldValidator NewPasswordRequired = new RequiredFieldValidator ();
				NewPasswordRequired.ID = "NewPasswordRequired";
				NewPasswordRequired.ControlToValidate = "NewPassword";
				NewPasswordRequired.ErrorMessage = _owner.PasswordRequiredErrorMessage;
				NewPasswordRequired.ToolTip = _owner.PasswordRequiredErrorMessage;
				NewPasswordRequired.Text = "*";
				NewPasswordRequired.ValidationGroup = _owner.ID;
				NewPasswordRequired.ApplyStyle (_owner.ValidatorTextStyle);

				table.Controls.Add (CreateRow (NewPasswordLabel, NewPassword, NewPasswordRequired, _owner.LabelStyle, null));

				// Row #5
				if (_owner.PasswordHintText.Length > 0) {
					table.Controls.Add (
						CreateRow (new LiteralControl (""),
							new LiteralControl (_owner.PasswordHintText),
							new LiteralControl (""),
							null, _owner.PasswordHintStyle));
				}

				// Row #6
				TextBox ConfirmNewPassword = new TextBox ();
				ConfirmNewPassword.ID = "ConfirmNewPassword";
				ConfirmNewPassword.TextMode = TextBoxMode.Password;
				ConfirmNewPassword.ApplyStyle (_owner.TextBoxStyle);

				Label ConfirmNewPasswordLabel = new Label ();
				ConfirmNewPasswordLabel.ID = "ConfirmNewPasswordLabel";
				ConfirmNewPasswordLabel.AssociatedControlID = "ConfirmNewPasswordLabel";
				ConfirmNewPasswordLabel.Text = _owner.ConfirmNewPasswordLabelText;

				RequiredFieldValidator ConfirmNewPasswordRequired = new RequiredFieldValidator ();
				ConfirmNewPasswordRequired.ID = "ConfirmNewPasswordRequired";
				ConfirmNewPasswordRequired.ControlToValidate = "ConfirmNewPassword";
				ConfirmNewPasswordRequired.ErrorMessage = _owner.PasswordRequiredErrorMessage;
				ConfirmNewPasswordRequired.ToolTip = _owner.PasswordRequiredErrorMessage;
				ConfirmNewPasswordRequired.Text = "*";
				ConfirmNewPasswordRequired.ValidationGroup = _owner.ID;
				ConfirmNewPasswordRequired.ApplyStyle (_owner.ValidatorTextStyle);

				table.Controls.Add (CreateRow (ConfirmNewPasswordLabel, ConfirmNewPassword, ConfirmNewPasswordRequired, _owner.LabelStyle, null));

				// Row #7
				CompareValidator NewPasswordCompare = new CompareValidator ();
				NewPasswordCompare.ID = "NewPasswordCompare";
				NewPasswordCompare.ControlToCompare = "NewPassword";
				NewPasswordCompare.ControlToValidate = "ConfirmNewPassword";
				NewPasswordCompare.Display = ValidatorDisplay.Dynamic;
				NewPasswordCompare.ErrorMessage = _owner.ConfirmPasswordCompareErrorMessage;
				NewPasswordCompare.ValidationGroup = _owner.ID;

				table.Controls.Add (CreateRow (NewPasswordCompare, null, null, null, null));

				// Row #8
				Literal FailureTextLiteral = new Literal ();
				FailureTextLiteral.ID = "FailureText";
				FailureTextLiteral.EnableViewState = false;

				if (_owner.FailureTextStyle.ForeColor.IsEmpty)
					_owner.FailureTextStyle.ForeColor = System.Drawing.Color.Red;

				table.Controls.Add (CreateRow (FailureTextLiteral, null, null, _owner.FailureTextStyle, null));

				// Row #9
				WebControl ChangePasswordButton = null;
				switch (_owner.ChangePasswordButtonType) {
					case ButtonType.Button:
						ChangePasswordButton = new Button ();
						break;
					case ButtonType.Image:
						ChangePasswordButton = new ImageButton ();
						break;
					case ButtonType.Link:
						ChangePasswordButton = new LinkButton ();
						break;
				}

				ChangePasswordButton.ID = "ChangePasswordPushButton";
				ChangePasswordButton.ApplyStyle (_owner.ChangePasswordButtonStyle);
				((IButtonControl) ChangePasswordButton).CommandName = ChangePassword.ChangePasswordButtonCommandName;
				((IButtonControl) ChangePasswordButton).Text = _owner.ChangePasswordButtonText;
				((IButtonControl) ChangePasswordButton).ValidationGroup = _owner.ID;

				WebControl CancelButton = null;
				switch (_owner.CancelButtonType) {
					case ButtonType.Button:
						CancelButton = new Button ();
						break;
					case ButtonType.Image:
						CancelButton = new ImageButton ();
						break;
					case ButtonType.Link:
						CancelButton = new LinkButton ();
						break;
				}

				CancelButton.ID = "CancelPushButton";
				CancelButton.ApplyStyle (_owner.CancelButtonStyle);
				((IButtonControl) CancelButton).CommandName = ChangePassword.CancelButtonCommandName;
				((IButtonControl) CancelButton).Text = _owner.CancelButtonText;
				((IButtonControl) CancelButton).CausesValidation = false;

				table.Controls.Add (CreateRow (ChangePasswordButton, CancelButton, new LiteralControl (""), null, null));

				// Row #10
				TableRow linksRow = new TableRow ();
				TableCell linksCell = new TableCell ();
				linksCell.ColumnSpan = 2;
				linksCell.ControlStyle.CopyFrom (_owner.HyperLinkStyle);

				linksRow.Cells.Add (linksCell);

				if (AddLink (_owner.HelpPageUrl, _owner.HelpPageText, _owner.HelpPageIconUrl, linksCell))
					linksCell.Controls.Add (new LiteralControl ("<br/>"));

				if (AddLink (_owner.CreateUserUrl, _owner.CreateUserText, _owner.CreateUserIconUrl, linksCell))
					linksCell.Controls.Add (new LiteralControl ("<br/>"));

				if (AddLink (_owner.PasswordRecoveryUrl, _owner.PasswordRecoveryText, _owner.PasswordRecoveryIconUrl, linksCell))
					linksCell.Controls.Add (new LiteralControl ("<br/>"));

				AddLink (_owner.EditProfileUrl, _owner.EditProfileText, _owner.EditProfileIconUrl, linksCell);

				table.Controls.Add (linksRow);

				container.Controls.Add (table);
			}
Exemple #2
0
			public void InstantiateIn (Control container)
			{
				Table table = new Table ();
				table.CellPadding = 0;

				bool twoCells = _owner.TextLayout == LoginTextLayout.TextOnLeft;

				// row 0
				table.Rows.Add (
					TemplateUtils.CreateRow (new LiteralControl (_owner.QuestionTitleText), null, _owner.TitleTextStyle, null, twoCells));

				// row 1
				table.Rows.Add (
					TemplateUtils.CreateRow (new LiteralControl (_owner.QuestionInstructionText), null, _owner.InstructionTextStyle, null, twoCells));

				// row 2
				Literal UserNameLiteral = new Literal ();
				UserNameLiteral.ID = "UserName";

				table.Rows.Add (
					TemplateUtils.CreateRow (new LiteralControl (_owner.UserNameLabelText), UserNameLiteral, _owner.LabelStyle, _owner.LabelStyle, twoCells));

				// row 3
				Literal QuestionLiteral = new Literal ();
				QuestionLiteral.ID = "Question";

				table.Rows.Add (
					TemplateUtils.CreateRow (new LiteralControl (_owner.QuestionLabelText), QuestionLiteral, _owner.LabelStyle, _owner.LabelStyle, twoCells));

				// row 5
				TextBox AnswerTextBox = new TextBox ();
				AnswerTextBox.ID = "Answer";
				AnswerTextBox.ApplyStyle (_owner.TextBoxStyle);

				Label AnswerLabel = new Label ();
				AnswerLabel.ID = "AnswerLabel";
				AnswerLabel.AssociatedControlID = "Answer";
				AnswerLabel.Text = _owner.AnswerLabelText;
				AnswerLabel.ApplyStyle (_owner.LabelStyle);

				RequiredFieldValidator AnswerRequired = new RequiredFieldValidator ();
				AnswerRequired.ID = "AnswerRequired";
				AnswerRequired.ControlToValidate = "Answer";
				AnswerRequired.ErrorMessage = _owner.AnswerRequiredErrorMessage;
				AnswerRequired.ToolTip = _owner.AnswerRequiredErrorMessage;
				AnswerRequired.Text = "*";
				AnswerRequired.ValidationGroup = _owner.ID;
				AnswerRequired.ApplyStyle (_owner.ValidatorTextStyle);

				if (twoCells) {
					TableRow row = TemplateUtils.CreateRow (AnswerLabel, AnswerTextBox, null, null, twoCells);
					row.Cells [1].Controls.Add (AnswerRequired);
					table.Rows.Add (row);
				}
				else {
					table.Rows.Add (TemplateUtils.CreateRow (AnswerLabel, null, null, null, twoCells));
					TableRow row = TemplateUtils.CreateRow (AnswerTextBox, null, null, null, twoCells);
					row.Cells [0].Controls.Add (AnswerRequired);
					table.Rows.Add (row);
				}

				// row 6
				Literal FailureText = new Literal ();
				FailureText.ID = "FailureText";
				if (_owner.FailureTextStyle.ForeColor.IsEmpty)
					_owner.FailureTextStyle.ForeColor = System.Drawing.Color.Red;
				table.Rows.Add (TemplateUtils.CreateRow (FailureText, null, _owner.FailureTextStyle, null, twoCells));

				// row 7
				WebControl SubmitButton = null;
				switch (_owner.SubmitButtonType) {
					case ButtonType.Button:
						SubmitButton = new Button ();
						break;
					case ButtonType.Image:
						SubmitButton = new ImageButton ();
						break;
					case ButtonType.Link:
						SubmitButton = new LinkButton ();
						break;
				}

				SubmitButton.ID = "SubmitButton";
				SubmitButton.ApplyStyle (_owner.SubmitButtonStyle);
				((IButtonControl) SubmitButton).CommandName = PasswordRecovery.SubmitButtonCommandName;
				((IButtonControl) SubmitButton).Text = _owner.SubmitButtonText;
				((IButtonControl) SubmitButton).ValidationGroup = _owner.ID;

				TableRow buttonRow = TemplateUtils.CreateRow (SubmitButton, null, null, null, twoCells);
				buttonRow.Cells [0].HorizontalAlign = HorizontalAlign.Right;
				table.Rows.Add (buttonRow);

				// row 8
				table.Rows.Add (
					TemplateUtils.CreateHelpRow (
					_owner.HelpPageUrl, _owner.HelpPageText, _owner.HelpPageIconUrl, _owner.HyperLinkStyle, twoCells));

				container.Controls.Add (table);
			}