public void InstantiateIn (Control container)
{
Table table = new Table ();
table.CellPadding = 0;
#if NET_4_0
Style ownerStyle = _owner.ControlStyle;
Style tableStyle = table.ControlStyle;
FontInfo ownerFont = ownerStyle.Font;
tableStyle.Font.CopyFrom (ownerFont);
ownerFont.ClearDefaults ();
Color ownerForeColor = ownerStyle.ForeColor;
if (ownerForeColor != Color.Empty) {
tableStyle.ForeColor = ownerForeColor;
ownerStyle.RemoveBit ((int)global::System.Web.UI.WebControls.Style.Styles.ForeColor);
}
#endif
// 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 (String.Empty),
new LiteralControl (_owner.PasswordHintText),
new LiteralControl (String.Empty),
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 (String.Empty), 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);
}
}