+2007-01-15 Igor Zelmanovich <igorz@mainsoft.com>
+
+ * CompleteWizardStep.cs
+ * CreateUserWizard.cs
+ * CreateUserWizardStep.cs
+ * TemplatedWizardStep.cs
+ * Wizard.cs
+ make the design complied to .NET
+ build all possible controls at once and manage render by Visible property
+
2007-01-14 Eyal Alaluf <eyala@mainsoft.com>
* Button.cs, HyperLink.cs, DataGrid.cs, ImageButton.cs, LinkButton.cs,
PagedDataSource.cs: Added J2EE Portal support for TARGET_J2EE.
}
}
- sealed class CompleteStepTemplate : ITemplate
- {
- readonly CreateUserWizard _createUserWizard;
-
- public CompleteStepTemplate (CreateUserWizard createUserWizard)
- {
- _createUserWizard = createUserWizard;
- }
-
- #region ITemplate Members
-
- public void InstantiateIn (Control container)
- {
- Table table = new Table ();
-
- // Row #0
- TableRow row0 = new TableRow ();
- TableCell cell00 = new TableCell ();
-
- cell00.HorizontalAlign = HorizontalAlign.Center;
- cell00.ColumnSpan = 2;
- cell00.ControlStyle.CopyFrom (_createUserWizard.TitleTextStyle);
- cell00.Controls.Add (new LiteralControl (_createUserWizard.CompleteStep.Title));
- row0.Cells.Add (cell00);
-
- // Row #1
- TableRow row1 = new TableRow ();
- TableCell cell10 = new TableCell ();
-
- cell10.HorizontalAlign = HorizontalAlign.Center;
- cell10.ControlStyle.CopyFrom (_createUserWizard.CompleteSuccessTextStyle);
- cell10.Controls.Add (new LiteralControl (_createUserWizard.CompleteSuccessText));
- row1.Cells.Add (cell10);
-
- // Row #2
- TableRow row2 = new TableRow ();
- TableCell cell20 = new TableCell ();
-
- cell20.HorizontalAlign = HorizontalAlign.Right;
- cell20.ColumnSpan = 2;
- row2.Cells.Add (cell20);
-
- Control b = _createUserWizard.CreateButton ("ContinueButtonButton", CreateUserWizard.ContinueButtonCommandName, _createUserWizard.ContinueButtonType, _createUserWizard.ContinueButtonText, _createUserWizard.ContinueButtonImageUrl, _createUserWizard.ContinueButtonStyle, true);
- cell20.Controls.Add (b);
-
- // table
- table.Rows.Add (row0);
- table.Rows.Add (row1);
- table.Rows.Add (row2);
-
- container.Controls.Add (table);
- }
-
- #endregion
- }
-
}
#endif
private TableItemStyle _labelStyle = null;
private TableItemStyle _passwordHintStyle = null;
private TableItemStyle _titleTextStyle = null;
+ Style _createUserButtonStyle;
+ Style _continueButtonStyle;
private static readonly object CreatedUserEvent = new object ();
private static readonly object CreateUserErrorEvent = new object ();
public virtual string ContinueButtonImageUrl
{
- get { return base.FinishCompleteButtonImageUrl; }
- set { base.FinishCompleteButtonImageUrl = value; }
+ get { return ViewState.GetString ("ContinueButtonImageUrl", String.Empty); }
+ set { ViewState ["ContinueButtonImageUrl"] = value; }
}
public Style ContinueButtonStyle
{
- get
- {
- return base.FinishCompleteButtonStyle;
+ get {
+ if (_continueButtonStyle == null) {
+ _continueButtonStyle = new Style ();
+ if (IsTrackingViewState)
+ ((IStateManager) _continueButtonStyle).TrackViewState ();
+ }
+ return _continueButtonStyle;
}
}
[LocalizableAttribute (true)]
public virtual string ContinueButtonText
{
- get
- {
- object o = ViewState ["ContinueButtonText"];
- return (o == null) ? Locale.GetText ("Continue") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("ContinueButtonText");
- else
- ViewState ["ContinueButtonText"] = value;
- }
+ get { return ViewState.GetString ("ContinueButtonText", "Continue"); }
+ set { ViewState ["ContinueButtonText"] = value; }
}
- [MonoTODO ("This should be saved to viewstate")]
public virtual ButtonType ContinueButtonType
{
- get { return base.FinishCompleteButtonType; }
- set { base.FinishCompleteButtonType = value; }
+ get {
+ object v = ViewState ["ContinueButtonType"];
+ return v != null ? (ButtonType) v : ButtonType.Button;
+ }
+ set {
+ ViewState ["ContinueButtonType"] = value;
+ }
}
[ThemeableAttribute (false)]
public virtual string CreateUserButtonImageUrl
{
- get { return base.StartNextButtonImageUrl; }
- set { StartNextButtonImageUrl = value; }
+ get { return ViewState.GetString ("CreateUserButtonImageUrl", String.Empty); }
+ set { ViewState ["CreateUserButtonImageUrl"] = value; }
}
public Style CreateUserButtonStyle
{
- get
- {
- return base.StartNextButtonStyle;
+ get {
+ if (_createUserButtonStyle == null) {
+ _createUserButtonStyle = new Style ();
+ if (IsTrackingViewState)
+ ((IStateManager) _createUserButtonStyle).TrackViewState ();
+ }
+ return _createUserButtonStyle;
}
}
[LocalizableAttribute (true)]
public virtual string CreateUserButtonText
{
- get
- {
- object o = ViewState ["CreateUserButtonText"];
- return (o == null) ? Locale.GetText ("Create User") : (string) o;
- }
- set
- {
- if (value == null)
- ViewState.Remove ("CreateUserButtonText");
- else
- ViewState ["CreateUserButtonText"] = value;
- }
+ get { return ViewState.GetString ("CreateUserButtonText", "Create User"); }
+ set { ViewState ["CreateUserButtonText"] = value; }
}
- [MonoTODO ("This should be saved to viewstate")]
public virtual ButtonType CreateUserButtonType
{
- get { return base.StartNextButtonType; }
- set { base.StartNextButtonType = value; }
+ get {
+ object v = ViewState ["CreateUserButtonType"];
+ return v != null ? (ButtonType) v : ButtonType.Button;
+ }
+ set {
+ ViewState ["CreateUserButtonType"] = value;
+ }
}
public CreateUserWizardStep CreateUserStep
private void InstantiateCompleteWizardStep (CompleteWizardStep step)
{
- BaseWizardContainer contentTemplateContainer = new BaseWizardContainer ();
- contentTemplateContainer.InstatiateTemplate (step.ContentTemplate != null ? step.ContentTemplate : new CompleteStepTemplate (this));
+ CompleteStepContainer contentTemplateContainer = new CompleteStepContainer (this);
+ if (step.ContentTemplate != null) {
+ step.ContentTemplate.InstantiateIn (contentTemplateContainer.InnerCell);
+ }
+ else {
+ new CompleteStepTemplate (this).InstantiateIn (contentTemplateContainer.InnerCell);
+ contentTemplateContainer.ConfirmDefaultTemplate ();
+ }
step.ContentTemplateContainer = contentTemplateContainer;
step.Controls.Clear ();
void InstantiateCreateUserWizardStep (CreateUserWizardStep step)
{
- BaseWizardContainer contentTemplateContainer = new CreateUserStepContainer ();
- contentTemplateContainer.InstatiateTemplate (step.ContentTemplate != null ? step.ContentTemplate : new CreateUserStepTemplate (this));
+ CreateUserStepContainer contentTemplateContainer = new CreateUserStepContainer (this);
+ if (step.ContentTemplate != null) {
+ step.ContentTemplate.InstantiateIn (contentTemplateContainer.InnerCell);
+ }
+ else {
+ new CreateUserStepTemplate (this).InstantiateIn (contentTemplateContainer.InnerCell);
+ contentTemplateContainer.ConfirmDefaultTemplate ();
+ contentTemplateContainer.EnsureValidatorsState ();
+ }
step.ContentTemplateContainer = contentTemplateContainer;
step.Controls.Clear ();
step.Controls.Add (contentTemplateContainer);
- BaseWizardNavigationContainer customNavigationTemplateContainer = new BaseWizardNavigationContainer ();
- (step.CustomNavigationTemplate != null ? step.CustomNavigationTemplate : new CreateUserStepNavigationTemplate (this)).InstantiateIn (customNavigationTemplateContainer);
+ CreateUserNavigationContainer customNavigationTemplateContainer = new CreateUserNavigationContainer (this);
+ if (step.CustomNavigationTemplate != null) {
+ step.CustomNavigationTemplate.InstantiateIn (customNavigationTemplateContainer);
+ }
+ else {
+ new CreateUserStepNavigationTemplate (this).InstantiateIn (customNavigationTemplateContainer);
+ customNavigationTemplateContainer.ConfirmDefaultTemplate ();
+ }
RegisterCustomNavigation (step, customNavigationTemplateContainer);
step.CustomNavigationTemplateContainer = customNavigationTemplateContainer;
protected internal override void CreateChildControls ()
{
- CreateUserWizardStep c = CreateUserStep;
+ if (CreateUserStep == null)
+ WizardSteps.AddAt (0, new CreateUserWizardStep ());
+
+ if (CompleteStep == null)
+ WizardSteps.AddAt (WizardSteps.Count, new CompleteWizardStep ());
base.CreateChildControls ();
}
throw new NotImplementedException ();
}
- protected internal override void OnInit (EventArgs e)
- {
- base.OnInit (e);
-
- if (CreateUserStep == null)
- WizardSteps.AddAt (0, new CreateUserWizardStep ());
-
- if (CompleteStep == null)
- WizardSteps.AddAt (WizardSteps.Count, new CompleteWizardStep ());
-
- if (ActiveStepIndex < 0)
- ActiveStepIndex = 0;
- }
-
protected override bool OnBubbleEvent (object source, EventArgs e)
{
CommandEventArgs args = e as CommandEventArgs;
object [] states = (object []) savedState;
base.LoadViewState (states [0]);
- if (states [1] != null) ((IStateManager) TextBoxStyle).LoadViewState (states [1]);
- if (states [2] != null) ((IStateManager) ValidatorTextStyle).LoadViewState (states [2]);
- if (states [3] != null) ((IStateManager) CompleteSuccessTextStyle).LoadViewState (states [3]);
- if (states [4] != null) ((IStateManager) ErrorMessageStyle).LoadViewState (states [4]);
- if (states [5] != null) ((IStateManager) HyperLinkStyle).LoadViewState (states [5]);
- if (states [6] != null) ((IStateManager) InstructionTextStyle).LoadViewState (states [6]);
- if (states [7] != null) ((IStateManager) LabelStyle).LoadViewState (states [7]);
- if (states [8] != null) ((IStateManager) PasswordHintStyle).LoadViewState (states [8]);
- if (states [9] != null) ((IStateManager) TitleTextStyle).LoadViewState (states [9]);
+ if (states [1] != null)
+ ((IStateManager) TextBoxStyle).LoadViewState (states [1]);
+ if (states [2] != null)
+ ((IStateManager) ValidatorTextStyle).LoadViewState (states [2]);
+ if (states [3] != null)
+ ((IStateManager) CompleteSuccessTextStyle).LoadViewState (states [3]);
+ if (states [4] != null)
+ ((IStateManager) ErrorMessageStyle).LoadViewState (states [4]);
+ if (states [5] != null)
+ ((IStateManager) HyperLinkStyle).LoadViewState (states [5]);
+ if (states [6] != null)
+ ((IStateManager) InstructionTextStyle).LoadViewState (states [6]);
+ if (states [7] != null)
+ ((IStateManager) LabelStyle).LoadViewState (states [7]);
+ if (states [8] != null)
+ ((IStateManager) PasswordHintStyle).LoadViewState (states [8]);
+ if (states [9] != null)
+ ((IStateManager) TitleTextStyle).LoadViewState (states [9]);
+ if (states [10] != null)
+ ((IStateManager) CreateUserButtonStyle).LoadViewState (states [10]);
+ if (states [11] != null)
+ ((IStateManager) ContinueButtonStyle).LoadViewState (states [11]);
+
+ ((CreateUserStepContainer) CreateUserStep.ContentTemplateContainer).EnsureValidatorsState ();
}
protected override object SaveViewState ()
{
- object [] state = new object [10];
+ object [] state = new object [12];
state [0] = base.SaveViewState ();
- if (TextBoxStyle != null) state [1] = ((IStateManager) TextBoxStyle).SaveViewState ();
- if (ValidatorTextStyle != null) state [2] = ((IStateManager) ValidatorTextStyle).SaveViewState ();
- if (CompleteSuccessTextStyle != null) state [3] = ((IStateManager) CompleteSuccessTextStyle).SaveViewState ();
- if (ErrorMessageStyle != null) state [4] = ((IStateManager) ErrorMessageStyle).SaveViewState ();
- if (HyperLinkStyle != null) state [5] = ((IStateManager) HyperLinkStyle).SaveViewState ();
- if (InstructionTextStyle != null) state [6] = ((IStateManager) InstructionTextStyle).SaveViewState ();
- if (LabelStyle != null) state [7] = ((IStateManager) LabelStyle).SaveViewState ();
- if (PasswordHintStyle != null) state [8] = ((IStateManager) PasswordHintStyle).SaveViewState ();
- if (TitleTextStyle != null) state [9] = ((IStateManager) TitleTextStyle).SaveViewState ();
+ if (_textBoxStyle != null)
+ state [1] = ((IStateManager) _textBoxStyle).SaveViewState ();
+ if (_validatorTextStyle != null)
+ state [2] = ((IStateManager) _validatorTextStyle).SaveViewState ();
+ if (_completeSuccessTextStyle != null)
+ state [3] = ((IStateManager) _completeSuccessTextStyle).SaveViewState ();
+ if (_errorMessageStyle != null)
+ state [4] = ((IStateManager) _errorMessageStyle).SaveViewState ();
+ if (_hyperLinkStyle != null)
+ state [5] = ((IStateManager) _hyperLinkStyle).SaveViewState ();
+ if (_instructionTextStyle != null)
+ state [6] = ((IStateManager) _instructionTextStyle).SaveViewState ();
+ if (_labelStyle != null)
+ state [7] = ((IStateManager) _labelStyle).SaveViewState ();
+ if (_passwordHintStyle != null)
+ state [8] = ((IStateManager) _passwordHintStyle).SaveViewState ();
+ if (_titleTextStyle != null)
+ state [9] = ((IStateManager) _titleTextStyle).SaveViewState ();
+ if (_createUserButtonStyle != null)
+ state [10] = ((IStateManager) _createUserButtonStyle).SaveViewState ();
+ if (_continueButtonStyle != null)
+ state [11] = ((IStateManager) _continueButtonStyle).SaveViewState ();
for (int n = 0; n < state.Length; n++)
- if (state [n] != null) return state;
+ if (state [n] != null)
+ return state;
return null;
}
protected override void TrackViewState ()
{
base.TrackViewState ();
- if (_textBoxStyle != null) ((IStateManager) _textBoxStyle).TrackViewState ();
- if (_validatorTextStyle != null) ((IStateManager) _validatorTextStyle).TrackViewState ();
- if (_completeSuccessTextStyle != null) ((IStateManager) _completeSuccessTextStyle).TrackViewState ();
- if (_errorMessageStyle != null) ((IStateManager) _errorMessageStyle).TrackViewState ();
- if (_hyperLinkStyle != null) ((IStateManager) _hyperLinkStyle).TrackViewState ();
- if (_instructionTextStyle != null) ((IStateManager) _instructionTextStyle).TrackViewState ();
- if (_labelStyle != null) ((IStateManager) _labelStyle).TrackViewState ();
- if (_passwordHintStyle != null) ((IStateManager) _passwordHintStyle).TrackViewState ();
- if (_titleTextStyle != null) ((IStateManager) _titleTextStyle).TrackViewState ();
+ if (_textBoxStyle != null)
+ ((IStateManager) _textBoxStyle).TrackViewState ();
+ if (_validatorTextStyle != null)
+ ((IStateManager) _validatorTextStyle).TrackViewState ();
+ if (_completeSuccessTextStyle != null)
+ ((IStateManager) _completeSuccessTextStyle).TrackViewState ();
+ if (_errorMessageStyle != null)
+ ((IStateManager) _errorMessageStyle).TrackViewState ();
+ if (_hyperLinkStyle != null)
+ ((IStateManager) _hyperLinkStyle).TrackViewState ();
+ if (_instructionTextStyle != null)
+ ((IStateManager) _instructionTextStyle).TrackViewState ();
+ if (_labelStyle != null)
+ ((IStateManager) _labelStyle).TrackViewState ();
+ if (_passwordHintStyle != null)
+ ((IStateManager) _passwordHintStyle).TrackViewState ();
+ if (_titleTextStyle != null)
+ ((IStateManager) _titleTextStyle).TrackViewState ();
+ if (_createUserButtonStyle != null)
+ ((IStateManager) _createUserButtonStyle).TrackViewState ();
+ if (_continueButtonStyle != null)
+ ((IStateManager) _continueButtonStyle).TrackViewState ();
}
#endregion
public void InstantiateIn (Control control)
{
Label b = new Label ();
- wizard.RegisterApplyStyle (b, wizard.SideBarButtonStyle, false);
+ wizard.RegisterApplyStyle (b, wizard.SideBarButtonStyle);
control.Controls.Add (b);
control.DataBinding += Bound;
}
}
#endregion
+
+ sealed class CreateUserNavigationContainer : DefaultNavigationContainer
+ {
+ CreateUserWizard _createUserWizard;
+
+ public CreateUserNavigationContainer (CreateUserWizard createUserWizard)
+ : base (createUserWizard)
+ {
+ _createUserWizard = createUserWizard;
+ }
+
+ protected override void UpdateState ()
+ {
+ // previous
+ if (_createUserWizard.AllowNavigationToStep (_createUserWizard.ActiveStepIndex - 1)) {
+ UpdateNavButtonState (Wizard.StepPreviousButtonID + Wizard.StepPreviousButtonType, Wizard.StepPreviousButtonText, Wizard.StepPreviousButtonImageUrl, Wizard.StepPreviousButtonStyle);
+ }
+ else {
+ ((Table) Controls [0]).Rows [0].Cells [0].Visible = false;
+ }
+
+ // create user
+ UpdateNavButtonState (Wizard.StepNextButtonID + _createUserWizard.CreateUserButtonType, _createUserWizard.CreateUserButtonText, _createUserWizard.CreateUserButtonImageUrl, _createUserWizard.CreateUserButtonStyle);
+
+ // cancel
+ if (Wizard.DisplayCancelButton) {
+ UpdateNavButtonState (Wizard.CancelButtonID + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
+ }
+ else {
+ ((Table) Controls [0]).Rows [0].Cells [2].Visible = false;
+ }
+ }
+ }
+
+ sealed class CreateUserStepNavigationTemplate : ITemplate
+ {
+ readonly CreateUserWizard _createUserWizard;
+
+ public CreateUserStepNavigationTemplate (CreateUserWizard createUserWizard) {
+ _createUserWizard = createUserWizard;
+ }
+
+ #region ITemplate Members
+
+ public void InstantiateIn (Control container) {
+ Table t = new Table ();
+ t.CellPadding = 5;
+ t.CellSpacing = 5;
+ t.Width = Unit.Percentage (100);
+ t.Height = Unit.Percentage (100);
+ TableRow row = new TableRow ();
+
+ AddButtonCell (row, _createUserWizard.CreateButtonSet (Wizard.StepPreviousButtonID, Wizard.MovePreviousCommandName, false));
+ AddButtonCell (row, _createUserWizard.CreateButtonSet (Wizard.StepNextButtonID, Wizard.MoveNextCommandName));
+ AddButtonCell (row, _createUserWizard.CreateButtonSet (Wizard.CancelButtonID, Wizard.CancelCommandName, false));
+
+ t.Rows.Add (row);
+ container.Controls.Add (t);
+ }
+
+ void AddButtonCell (TableRow row, params Control [] controls)
+ {
+ TableCell cell = new TableCell ();
+ cell.HorizontalAlign = HorizontalAlign.Right;
+ for (int i = 0; i < controls.Length; i++)
+ cell.Controls.Add (controls[i]);
+ row.Cells.Add (cell);
+ }
+
+ #endregion
+ }
+
+ sealed class CreateUserStepContainer : DefaultContentContainer
+ {
+ CreateUserWizard _createUserWizard;
+
+ public CreateUserStepContainer (CreateUserWizard createUserWizard)
+ : base (createUserWizard)
+ {
+ _createUserWizard = createUserWizard;
+ }
+
+ public Control UserNameTextBox {
+ get {
+ Control c = FindControl ("UserName");
+ if (c == null)
+ throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID UserName for the username.");
+
+ return c;
+ }
+ }
+ public Control PasswordTextBox {
+ get {
+ Control c = FindControl ("Password");
+ if (c == null)
+ throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Password for the new password, this is required if AutoGeneratePassword = true.");
+
+ return c;
+ }
+ }
+ public Control ConfirmPasswordTextBox {
+ get {
+ Control c = FindControl ("Password");
+ return c;
+ }
+ }
+ public Control EmailTextBox {
+ get {
+ Control c = FindControl ("Email");
+ if (c == null)
+ throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Email for the e-mail, this is required if RequireEmail = true.");
+
+ return c;
+ }
+ }
+ public Control QuestionTextBox {
+ get {
+ Control c = FindControl ("Question");
+ if (c == null)
+ throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Question for the security question, this is required if your membership provider requires a question and answer.");
+
+ return c;
+ }
+ }
+ public Control AnswerTextBox {
+ get {
+ Control c = FindControl ("Answer");
+ if (c == null)
+ throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Answer for the security answer, this is required if your membership provider requires a question and answer.");
+
+ return c;
+ }
+ }
+ public ITextControl ErrorMessageLabel {
+ get { return FindControl ("ErrorMessage") as ITextControl; }
+ }
+
+ protected override void UpdateState () {
+ // Row #0 - title
+ if (String.IsNullOrEmpty (_createUserWizard.CreateUserStep.Title)) {
+ ((Table) InnerCell.Controls [0]).Rows [0].Visible = false;
+ }
+ else {
+ ((Table) InnerCell.Controls [0]).Rows [0].Cells [0].Text = _createUserWizard.CreateUserStep.Title;
+ }
+
+ // Row #1 - InstructionText
+ if (String.IsNullOrEmpty (_createUserWizard.InstructionText)) {
+ ((Table) InnerCell.Controls [0]).Rows [1].Visible = false;
+ }
+ else {
+ ((Table) InnerCell.Controls [0]).Rows [1].Cells [0].Text = _createUserWizard.InstructionText;
+ }
+
+ // Row #2
+ Label UserNameLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [2].Cells [0].Controls [0];
+ UserNameLabel.Text = _createUserWizard.UserNameLabelText;
+
+ RequiredFieldValidator UserNameRequired = (RequiredFieldValidator) FindControl ("UserNameRequired");
+ UserNameRequired.ErrorMessage = _createUserWizard.UserNameRequiredErrorMessage;
+ UserNameRequired.ToolTip = _createUserWizard.UserNameRequiredErrorMessage;
+
+ if (_createUserWizard.AutoGeneratePassword) {
+ ((Table) InnerCell.Controls [0]).Rows [3].Visible = false;
+ ((Table) InnerCell.Controls [0]).Rows [4].Visible = false;
+ ((Table) InnerCell.Controls [0]).Rows [5].Visible = false;
+ }
+ else {
+ // Row #3
+ Label PasswordLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [3].Cells [0].Controls [0];
+ PasswordLabel.Text = _createUserWizard.PasswordLabelText;
+
+ RequiredFieldValidator PasswordRequired = (RequiredFieldValidator) FindControl ("PasswordRequired");
+ PasswordRequired.ErrorMessage = _createUserWizard.PasswordRequiredErrorMessage;
+ PasswordRequired.ToolTip = _createUserWizard.PasswordRequiredErrorMessage;
+
+ // Row #4
+ if (String.IsNullOrEmpty (_createUserWizard.PasswordHintText)) {
+ ((Table) InnerCell.Controls [0]).Rows [4].Visible = false;
+ }
+ else {
+ ((Table) InnerCell.Controls [0]).Rows [4].Cells [1].Text = _createUserWizard.PasswordHintText;
+ }
+
+ // Row #5
+ Label ConfirmPasswordLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [5].Cells [0].Controls [0];
+ ConfirmPasswordLabel.Text = _createUserWizard.ConfirmPasswordLabelText;
+
+ RequiredFieldValidator ConfirmPasswordRequired = (RequiredFieldValidator) FindControl ("ConfirmPasswordRequired");
+ ConfirmPasswordRequired.ErrorMessage = _createUserWizard.ConfirmPasswordRequiredErrorMessage;
+ ConfirmPasswordRequired.ToolTip = _createUserWizard.ConfirmPasswordRequiredErrorMessage;
+ }
+
+ // Row #6
+ if (_createUserWizard.RequireEmail) {
+ Label EmailLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [6].Cells [0].Controls [0];
+ EmailLabel.Text = _createUserWizard.EmailLabelText;
+
+ RequiredFieldValidator EmailRequired = (RequiredFieldValidator) FindControl ("EmailRequired");
+ EmailRequired.ErrorMessage = _createUserWizard.EmailRequiredErrorMessage;
+ EmailRequired.ToolTip = _createUserWizard.EmailRequiredErrorMessage;
+ }
+ else {
+ ((Table) InnerCell.Controls [0]).Rows [6].Visible = false;
+ }
+
+ if (_createUserWizard.QuestionAndAnswerRequired) {
+ // Row #7
+ Label QuestionLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [7].Cells [0].Controls [0];
+ QuestionLabel.Text = _createUserWizard.QuestionLabelText;
+
+ RequiredFieldValidator QuestionRequired = (RequiredFieldValidator) FindControl ("QuestionRequired");
+ QuestionRequired.ErrorMessage = _createUserWizard.QuestionRequiredErrorMessage;
+ QuestionRequired.ToolTip = _createUserWizard.QuestionRequiredErrorMessage;
+
+ // Row #8
+ Label AnswerLabel = (Label) ((Table) InnerCell.Controls [0]).Rows [8].Cells [0].Controls [0];
+ AnswerLabel.Text = _createUserWizard.AnswerLabelText;
+
+ RequiredFieldValidator AnswerRequired = (RequiredFieldValidator) FindControl ("AnswerRequired");
+ AnswerRequired.ErrorMessage = _createUserWizard.AnswerRequiredErrorMessage;
+ AnswerRequired.ToolTip = _createUserWizard.AnswerRequiredErrorMessage;
+ }
+ else {
+ ((Table) InnerCell.Controls [0]).Rows [7].Visible = false;
+ ((Table) InnerCell.Controls [0]).Rows [8].Visible = false;
+ }
+
+ // Row #9
+ if (_createUserWizard.AutoGeneratePassword) {
+ ((Table) InnerCell.Controls [0]).Rows [9].Visible = false;
+ }
+ else {
+ CompareValidator PasswordCompare = (CompareValidator) FindControl ("PasswordCompare");
+ PasswordCompare.ErrorMessage = _createUserWizard.ConfirmPasswordCompareErrorMessage;
+ }
+
+ // Row #10
+ if (_createUserWizard.AutoGeneratePassword || String.IsNullOrEmpty (_createUserWizard.PasswordRegularExpression)) {
+ ((Table) InnerCell.Controls [0]).Rows [10].Visible = false;
+ }
+ else {
+ RegularExpressionValidator PasswordRegEx = (RegularExpressionValidator) FindControl ("PasswordRegEx");
+ PasswordRegEx.ValidationExpression = _createUserWizard.PasswordRegularExpression;
+ PasswordRegEx.ErrorMessage = _createUserWizard.PasswordRegularExpressionErrorMessage;
+ }
+
+ // Row #11
+ if (!_createUserWizard.RequireEmail || String.IsNullOrEmpty (_createUserWizard.EmailRegularExpression)) {
+ ((Table) InnerCell.Controls [0]).Rows [11].Visible = false;
+ }
+ else {
+ RegularExpressionValidator EmailRegEx = (RegularExpressionValidator) FindControl ("EmailRegEx");
+ EmailRegEx.ErrorMessage = _createUserWizard.EmailRegularExpressionErrorMessage;
+ EmailRegEx.ValidationExpression = _createUserWizard.EmailRegularExpression;
+ }
+
+ // Row #12
+ if (String.IsNullOrEmpty (ErrorMessageLabel.Text)) {
+ ((Table) InnerCell.Controls [0]).Rows [12].Visible = false;
+ }
+
+ // Row #13
+ // HelpPageIconUrl
+ Image img = (Image) ((Table) InnerCell.Controls [0]).Rows [13].Cells [0].Controls [0];
+ if (String.IsNullOrEmpty (_createUserWizard.HelpPageIconUrl)) {
+ img.Visible = false;
+ }
+ else {
+ img.ImageUrl = _createUserWizard.HelpPageIconUrl;
+ img.AlternateText = _createUserWizard.HelpPageText;
+ }
+
+ // HelpPageText
+ HyperLink link = (HyperLink) ((Table) InnerCell.Controls [0]).Rows [13].Cells [0].Controls [1];
+ if (String.IsNullOrEmpty (_createUserWizard.HelpPageText)) {
+ link.Visible = false;
+ }
+ else {
+ link.Text = _createUserWizard.HelpPageText;
+ link.NavigateUrl = _createUserWizard.HelpPageUrl;
+ }
+
+ ((Table) InnerCell.Controls [0]).Rows [13].Visible = img.Visible || link.Visible;
+
+ }
+
+ public void EnsureValidatorsState ()
+ {
+ if (!IsDefaultTemplate)
+ return;
+
+ ((RequiredFieldValidator) FindControl ("PasswordRequired")).Enabled = !_createUserWizard.AutoGeneratePassword;
+ ((RequiredFieldValidator) FindControl ("ConfirmPasswordRequired")).Enabled = !_createUserWizard.AutoGeneratePassword;
+ ((CompareValidator) FindControl ("PasswordCompare")).Enabled = !_createUserWizard.AutoGeneratePassword;
+ RegularExpressionValidator PasswordRegEx = (RegularExpressionValidator) FindControl ("PasswordRegEx");
+ PasswordRegEx.Enabled = !_createUserWizard.AutoGeneratePassword && !String.IsNullOrEmpty (_createUserWizard.PasswordRegularExpression);
+ PasswordRegEx.ValidationExpression = _createUserWizard.PasswordRegularExpression;
+
+ ((RequiredFieldValidator) FindControl ("EmailRequired")).Enabled = _createUserWizard.RequireEmail;
+ RegularExpressionValidator EmailRegEx = (RegularExpressionValidator) FindControl ("EmailRegEx");
+ EmailRegEx.Enabled = _createUserWizard.RequireEmail && !String.IsNullOrEmpty (_createUserWizard.EmailRegularExpression);
+ EmailRegEx.ValidationExpression = _createUserWizard.EmailRegularExpression;
+
+ ((RequiredFieldValidator) FindControl ("QuestionRequired")).Enabled = _createUserWizard.QuestionAndAnswerRequired;
+ ((RequiredFieldValidator) FindControl ("AnswerRequired")).Enabled = _createUserWizard.QuestionAndAnswerRequired;
+ }
+ }
+
+ sealed class CreateUserStepTemplate : ITemplate
+ {
+ readonly CreateUserWizard _createUserWizard;
+
+ public CreateUserStepTemplate (CreateUserWizard createUserWizard)
+ {
+ _createUserWizard = createUserWizard;
+ }
+
+ #region ITemplate Members
+
+ TableRow CreateRow (Control c0, Control c1, Control c2, Style s0, Style s1) {
+ TableRow row = new TableRow ();
+ TableCell cell0 = new TableCell ();
+ TableCell cell1 = new TableCell ();
+
+ if (c0 != null)
+ cell0.Controls.Add (c0);
+ row.Controls.Add (cell0);
+
+ if ((c1 != null) && (c2 != null)) {
+ cell1.Controls.Add (c1);
+ cell1.Controls.Add (c2);
+ cell0.HorizontalAlign = HorizontalAlign.Right;
+
+ if (s0 != null)
+ _createUserWizard.RegisterApplyStyle (cell0, s0);
+ if (s1 != null)
+ _createUserWizard.RegisterApplyStyle (cell1, s1);
+
+ row.Controls.Add (cell1);
+ }
+ else {
+ cell0.ColumnSpan = 2;
+ cell0.HorizontalAlign = HorizontalAlign.Center;
+ if (s0 != null)
+ _createUserWizard.RegisterApplyStyle (cell0, s0);
+ }
+ return row;
+ }
+
+ public void InstantiateIn (Control container) {
+ Table table = new Table ();
+ table.ControlStyle.Width = Unit.Percentage (100);
+ table.ControlStyle.Height = Unit.Percentage (100);
+
+ // Row #0
+ table.Controls.Add (CreateRow (null, null, null, _createUserWizard.TitleTextStyle, null));
+
+ // Row #1
+ table.Controls.Add (CreateRow (null, null, null, _createUserWizard.InstructionTextStyle, null));
+
+ // Row #2
+ TextBox UserName = new TextBox ();
+ UserName.ID = "UserName";
+ _createUserWizard.RegisterApplyStyle (UserName, _createUserWizard.TextBoxStyle);
+
+ Label UserNameLabel = new Label ();
+ UserNameLabel.AssociatedControlID = "UserName";
+
+ RequiredFieldValidator UserNameRequired = new RequiredFieldValidator ();
+ UserNameRequired.ID = "UserNameRequired";
+ // alternatively we can create only required validators
+ // and reinstantiate collection when relevant property changes
+ UserNameRequired.EnableViewState = false;
+ UserNameRequired.ControlToValidate = "UserName";
+ UserNameRequired.Text = "*";
+ UserNameRequired.ValidationGroup = _createUserWizard.ID;
+ _createUserWizard.RegisterApplyStyle (UserNameRequired, _createUserWizard.ValidatorTextStyle);
+
+ table.Controls.Add (CreateRow (UserNameLabel, UserName, UserNameRequired, _createUserWizard.LabelStyle, null));
+
+ // Row #3
+ TextBox Password = new TextBox ();
+ Password.ID = "Password";
+ Password.TextMode = TextBoxMode.Password;
+ _createUserWizard.RegisterApplyStyle (Password, _createUserWizard.TextBoxStyle);
+
+ Label PasswordLabel = new Label ();
+ PasswordLabel.AssociatedControlID = "Password";
+
+ RequiredFieldValidator PasswordRequired = new RequiredFieldValidator ();
+ PasswordRequired.ID = "PasswordRequired";
+ PasswordRequired.EnableViewState = false;
+ PasswordRequired.ControlToValidate = "Password";
+ PasswordRequired.Text = "*";
+ //PasswordRequired.EnableViewState = false;
+ PasswordRequired.ValidationGroup = _createUserWizard.ID;
+ _createUserWizard.RegisterApplyStyle (PasswordRequired, _createUserWizard.ValidatorTextStyle);
+
+ table.Controls.Add (CreateRow (PasswordLabel, Password, PasswordRequired, _createUserWizard.LabelStyle, null));
+
+ // Row #4
+ table.Controls.Add (CreateRow (new LiteralControl (""), new LiteralControl (""), new LiteralControl (""), null, _createUserWizard.PasswordHintStyle));
+
+ // Row #5
+ TextBox ConfirmPassword = new TextBox ();
+ ConfirmPassword.ID = "ConfirmPassword";
+ ConfirmPassword.TextMode = TextBoxMode.Password;
+ _createUserWizard.RegisterApplyStyle (ConfirmPassword, _createUserWizard.TextBoxStyle);
+
+ Label ConfirmPasswordLabel = new Label ();
+ ConfirmPasswordLabel.AssociatedControlID = "ConfirmPassword";
+
+ RequiredFieldValidator ConfirmPasswordRequired = new RequiredFieldValidator ();
+ ConfirmPasswordRequired.ID = "ConfirmPasswordRequired";
+ ConfirmPasswordRequired.EnableViewState = false;
+ ConfirmPasswordRequired.ControlToValidate = "ConfirmPassword";
+ ConfirmPasswordRequired.Text = "*";
+ ConfirmPasswordRequired.ValidationGroup = _createUserWizard.ID;
+ _createUserWizard.RegisterApplyStyle (ConfirmPasswordRequired, _createUserWizard.ValidatorTextStyle);
+
+ table.Controls.Add (CreateRow (ConfirmPasswordLabel, ConfirmPassword, ConfirmPasswordRequired, _createUserWizard.LabelStyle, null));
+
+ // Row #6
+ TextBox Email = new TextBox ();
+ Email.ID = "Email";
+ _createUserWizard.RegisterApplyStyle (Email, _createUserWizard.TextBoxStyle);
+
+ Label EmailLabel = new Label ();
+ EmailLabel.AssociatedControlID = "Email";
+
+ RequiredFieldValidator EmailRequired = new RequiredFieldValidator ();
+ EmailRequired.ID = "EmailRequired";
+ EmailRequired.EnableViewState = false;
+ EmailRequired.ControlToValidate = "Email";
+ EmailRequired.Text = "*";
+ EmailRequired.ValidationGroup = _createUserWizard.ID;
+ _createUserWizard.RegisterApplyStyle (EmailRequired, _createUserWizard.ValidatorTextStyle);
+
+ table.Controls.Add (CreateRow (EmailLabel, Email, EmailRequired, _createUserWizard.LabelStyle, null));
+
+ // Row #7
+ TextBox Question = new TextBox ();
+ Question.ID = "Question";
+ _createUserWizard.RegisterApplyStyle (Question, _createUserWizard.TextBoxStyle);
+
+ Label QuestionLabel = new Label ();
+ QuestionLabel.AssociatedControlID = "Question";
+
+ RequiredFieldValidator QuestionRequired = new RequiredFieldValidator ();
+ QuestionRequired.ID = "QuestionRequired";
+ QuestionRequired.EnableViewState = false;
+ QuestionRequired.ControlToValidate = "Question";
+ QuestionRequired.Text = "*";
+ QuestionRequired.ValidationGroup = _createUserWizard.ID;
+ _createUserWizard.RegisterApplyStyle (QuestionRequired, _createUserWizard.ValidatorTextStyle);
+
+ table.Controls.Add (CreateRow (QuestionLabel, Question, QuestionRequired, _createUserWizard.LabelStyle, null));
+
+ // Row #8
+ TextBox Answer = new TextBox ();
+ Answer.ID = "Answer";
+ _createUserWizard.RegisterApplyStyle (Answer, _createUserWizard.TextBoxStyle);
+
+ Label AnswerLabel = new Label ();
+ AnswerLabel.AssociatedControlID = "Answer";
+
+ RequiredFieldValidator AnswerRequired = new RequiredFieldValidator ();
+ AnswerRequired.ID = "AnswerRequired";
+ AnswerRequired.EnableViewState = false;
+ AnswerRequired.ControlToValidate = "Answer";
+ AnswerRequired.Text = "*";
+ AnswerRequired.ValidationGroup = _createUserWizard.ID;
+ _createUserWizard.RegisterApplyStyle (AnswerRequired, _createUserWizard.ValidatorTextStyle);
+
+ table.Controls.Add (CreateRow (AnswerLabel, Answer, AnswerRequired, _createUserWizard.LabelStyle, null));
+
+ // Row #9
+ CompareValidator PasswordCompare = new CompareValidator ();
+ PasswordCompare.ID = "PasswordCompare";
+ PasswordCompare.EnableViewState = false;
+ PasswordCompare.ControlToCompare = "Password";
+ PasswordCompare.ControlToValidate = "ConfirmPassword";
+ PasswordCompare.Display = ValidatorDisplay.Static;
+ PasswordCompare.ValidationGroup = _createUserWizard.ID;
+ _createUserWizard.RegisterApplyStyle (PasswordCompare, _createUserWizard.ValidatorTextStyle);
+
+ table.Controls.Add (CreateRow (PasswordCompare, null, null, null, null));
+
+ // Row #10
+ RegularExpressionValidator PasswordRegEx = new RegularExpressionValidator ();
+ PasswordRegEx.ID = "PasswordRegEx";
+ PasswordRegEx.EnableViewState = false;
+ PasswordRegEx.ControlToValidate = "Password";
+ PasswordRegEx.Display = ValidatorDisplay.Static;
+ PasswordRegEx.ValidationGroup = _createUserWizard.ID;
+ _createUserWizard.RegisterApplyStyle (PasswordRegEx, _createUserWizard.ValidatorTextStyle);
+
+ table.Controls.Add (CreateRow (PasswordRegEx, null, null, null, null));
+
+ // Row #11
+ RegularExpressionValidator EmailRegEx = new RegularExpressionValidator ();
+ EmailRegEx.ID = "EmailRegEx";
+ EmailRegEx.EnableViewState = false;
+ EmailRegEx.ControlToValidate = "Email";
+ EmailRegEx.Display = ValidatorDisplay.Static;
+ EmailRegEx.ValidationGroup = _createUserWizard.ID;
+ _createUserWizard.RegisterApplyStyle (EmailRegEx, _createUserWizard.ValidatorTextStyle);
+
+ table.Controls.Add (CreateRow (EmailRegEx, null, null, null, null));
+
+ // Row #12
+ Label ErrorMessage = new Label ();
+ ErrorMessage.ID = "ErrorMessage";
+ ErrorMessage.EnableViewState = false;
+ _createUserWizard.RegisterApplyStyle (ErrorMessage, _createUserWizard.ValidatorTextStyle);
+
+ table.Controls.Add (CreateRow (ErrorMessage, null, null, null, null));
+
+ // Row #13
+ TableRow row13 = CreateRow (new Image (), null, null, null, null);
+
+ HyperLink HelpLink = new HyperLink ();
+ HelpLink.ID = "HelpLink";
+ _createUserWizard.RegisterApplyStyle (HelpLink, _createUserWizard.HyperLinkStyle);
+ row13.Cells [0].Controls.Add (HelpLink);
+
+ row13.Cells [0].HorizontalAlign = HorizontalAlign.Left;
+ table.Controls.Add (row13);
+
+ //
+ container.Controls.Add (table);
+ }
+
+ #endregion
+ }
+
+ sealed class CompleteStepContainer : DefaultContentContainer
+ {
+ CreateUserWizard _createUserWizard;
+
+ public CompleteStepContainer (CreateUserWizard createUserWizard)
+ : base (createUserWizard)
+ {
+ _createUserWizard = createUserWizard;
+ }
+
+ protected override void UpdateState ()
+ {
+ // title
+ if (String.IsNullOrEmpty (_createUserWizard.CompleteStep.Title)) {
+ ((Table) InnerCell.Controls [0]).Rows [0].Visible = false;
+ }
+ else {
+ ((Table) InnerCell.Controls [0]).Rows [0].Cells [0].Text = _createUserWizard.CompleteStep.Title;
+ }
+
+ // CompleteSuccessText
+ if (String.IsNullOrEmpty (_createUserWizard.CompleteSuccessText)) {
+ ((Table) InnerCell.Controls [0]).Rows [1].Visible = false;
+ }
+ else {
+ ((Table) InnerCell.Controls [0]).Rows [1].Cells [0].Text = _createUserWizard.CompleteSuccessText;
+ }
+
+ // ContinueButton
+ UpdateNavButtonState ("ContinueButton" + _createUserWizard.ContinueButtonType, _createUserWizard.ContinueButtonText, _createUserWizard.ContinueButtonImageUrl, _createUserWizard.ContinueButtonStyle);
+
+ // EditProfileIconUrl
+ Image img = (Image) ((Table) InnerCell.Controls [0]).Rows [3].Cells [0].Controls [0];
+ if (String.IsNullOrEmpty (_createUserWizard.EditProfileIconUrl)) {
+ img.Visible = false;
+ }
+ else {
+ img.ImageUrl = _createUserWizard.EditProfileIconUrl;
+ img.AlternateText = _createUserWizard.EditProfileText;
+ }
+
+ // EditProfileText
+ HyperLink link = (HyperLink) ((Table) InnerCell.Controls [0]).Rows [3].Cells [0].Controls [1];
+ if (String.IsNullOrEmpty (_createUserWizard.EditProfileText)) {
+ link.Visible = false;
+ }
+ else {
+ link.Text = _createUserWizard.EditProfileText;
+ link.NavigateUrl = _createUserWizard.EditProfileUrl;
+ }
+
+ ((Table) InnerCell.Controls [0]).Rows [3].Visible = img.Visible || link.Visible;
+ }
+
+ void UpdateNavButtonState (string id, string text, string image, Style style)
+ {
+ WebControl b = (WebControl) FindControl (id);
+ foreach (Control c in b.Parent.Controls)
+ c.Visible = b == c;
+
+ ((IButtonControl) b).Text = text;
+ ImageButton imgbtn = b as ImageButton;
+ if (imgbtn != null)
+ imgbtn.ImageUrl = image;
+
+ b.ApplyStyle (style);
+ }
+ }
+
+ sealed class CompleteStepTemplate : ITemplate
+ {
+ readonly CreateUserWizard _createUserWizard;
+
+ public CompleteStepTemplate (CreateUserWizard createUserWizard)
+ {
+ _createUserWizard = createUserWizard;
+ }
+
+ #region ITemplate Members
+
+ public void InstantiateIn (Control container)
+ {
+ Table table = new Table ();
+
+ // Row #0
+ TableRow row0 = new TableRow ();
+ TableCell cell00 = new TableCell ();
+
+ cell00.HorizontalAlign = HorizontalAlign.Center;
+ cell00.ColumnSpan = 2;
+ _createUserWizard.RegisterApplyStyle (cell00, _createUserWizard.TitleTextStyle);
+ row0.Cells.Add (cell00);
+
+ // Row #1
+ TableRow row1 = new TableRow ();
+ TableCell cell10 = new TableCell ();
+
+ cell10.HorizontalAlign = HorizontalAlign.Center;
+ _createUserWizard.RegisterApplyStyle (cell10, _createUserWizard.CompleteSuccessTextStyle);
+ row1.Cells.Add (cell10);
+
+ // Row #2
+ TableRow row2 = new TableRow ();
+ TableCell cell20 = new TableCell ();
+
+ cell20.HorizontalAlign = HorizontalAlign.Right;
+ cell20.ColumnSpan = 2;
+ row2.Cells.Add (cell20);
+
+ Control[] b = _createUserWizard.CreateButtonSet ("ContinueButton", CreateUserWizard.ContinueButtonCommandName);
+ for (int i = 0; i < b.Length; i++)
+ cell20.Controls.Add (b [i]);
+
+ // Row #3
+ TableRow row3 = new TableRow ();
+ TableCell cell30 = new TableCell ();
+
+ cell30.Controls.Add (new Image ());
+ HyperLink link = new HyperLink ();
+ link.ID = "EditProfileLink";
+ _createUserWizard.RegisterApplyStyle (link, _createUserWizard.HyperLinkStyle);
+ cell30.Controls.Add (link);
+ row3.Cells.Add (cell30);
+
+ // table
+ table.Rows.Add (row0);
+ table.Rows.Add (row1);
+ table.Rows.Add (row2);
+ table.Rows.Add (row3);
+
+ container.Controls.Add (table);
+ }
+
+ #endregion
+ }
}
}
set { throw new InvalidOperationException (); }
}
}
-
- internal sealed class CreateUserStepContainer : BaseWizardContainer
- {
- public CreateUserStepContainer ()
- {
- }
-
- public Control UserNameTextBox
- {
- get
- {
- Control c = FindControl ("UserName");
- if (c == null)
- throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID UserName for the username.");
-
- return c;
- }
- }
- public Control PasswordTextBox
- {
- get
- {
- Control c = FindControl ("Password");
- if (c == null)
- throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Password for the new password, this is required if AutoGeneratePassword = true.");
-
- return c;
- }
- }
- public Control ConfirmPasswordTextBox
- {
- get
- {
- Control c = FindControl ("Password");
- return c;
- }
- }
- public Control EmailTextBox
- {
- get
- {
- Control c = FindControl ("Email");
- if (c == null)
- throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Email for the e-mail, this is required if RequireEmail = true.");
-
- return c;
- }
- }
- public Control QuestionTextBox
- {
- get
- {
- Control c = FindControl ("Question");
- if (c == null)
- throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Question for the security question, this is required if your membership provider requires a question and answer.");
-
- return c;
- }
- }
- public Control AnswerTextBox
- {
- get
- {
- Control c = FindControl ("Answer");
- if (c == null)
- throw new HttpException ("CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Answer for the security answer, this is required if your membership provider requires a question and answer.");
-
- return c;
- }
- }
- public ITextControl ErrorMessageLabel
- {
- get { return FindControl ("ErrorMessage") as ITextControl; }
- }
- }
-
- sealed class CreateUserStepTemplate : ITemplate
- {
- readonly CreateUserWizard _createUserWizard;
-
- public CreateUserStepTemplate (CreateUserWizard createUserWizard)
- {
- _createUserWizard = createUserWizard;
- }
-
- #region ITemplate Members
-
- TableRow CreateRow (Control c0, Control c1, Control c2, Style s0, Style s1)
- {
- TableRow row = new TableRow ();
- TableCell cell0 = new TableCell ();
- TableCell cell1 = new TableCell ();
-
- cell0.Controls.Add (c0);
- row.Controls.Add (cell0);
-
- if ((c1 != null) && (c2 != null)) {
- cell1.Controls.Add (c1);
- cell1.Controls.Add (c2);
- cell0.HorizontalAlign = HorizontalAlign.Right;
-
- if (s0 != null)
- cell0.ApplyStyle (s0);
- if (s1 != null)
- cell1.ApplyStyle (s1);
-
- row.Controls.Add (cell1);
- }
- else {
- cell0.ColumnSpan = 2;
- cell0.HorizontalAlign = HorizontalAlign.Center;
- if (s0 != null)
- cell0.ApplyStyle (s0);
- }
- return row;
- }
-
- void ITemplate.InstantiateIn (Control container)
- {
- Table table = new Table ();
- table.ControlStyle.Width = Unit.Percentage (100);
- table.ControlStyle.Height = Unit.Percentage (100);
-
- // Row #0
- table.Controls.Add (
- CreateRow (new LiteralControl (_createUserWizard.CreateUserStep.Title),
- null, null, _createUserWizard.TitleTextStyle, null));
-
- // Row #1
- if (_createUserWizard.InstructionText.Length > 0) {
- table.Controls.Add (
- CreateRow (new LiteralControl (_createUserWizard.InstructionText),
- null, null, _createUserWizard.InstructionTextStyle, null));
- }
-
- // Row #2
- TextBox UserName = new TextBox ();
- UserName.ID = "UserName";
- UserName.ApplyStyle (_createUserWizard.TextBoxStyle);
-
- Label UserNameLabel = new Label ();
- UserNameLabel.AssociatedControlID = "UserName";
- UserNameLabel.Text = _createUserWizard.UserNameLabelText;
-
-
- RequiredFieldValidator UserNameRequired = new RequiredFieldValidator ();
- UserNameRequired.ID = "UserNameRequired";
- UserNameRequired.ControlToValidate = "UserName";
- UserNameRequired.ErrorMessage = _createUserWizard.UserNameRequiredErrorMessage;
- UserNameRequired.ToolTip = _createUserWizard.UserNameRequiredErrorMessage;
- UserNameRequired.Text = "*";
- UserNameRequired.ValidationGroup = _createUserWizard.ID;
- UserNameRequired.ApplyStyle (_createUserWizard.ValidatorTextStyle);
-
- table.Controls.Add (CreateRow (UserNameLabel, UserName, UserNameRequired, _createUserWizard.LabelStyle, null));
-
- // Row #3
- if (!_createUserWizard.AutoGeneratePassword) {
- TextBox Password = new TextBox ();
- Password.ID = "Password";
- Password.TextMode = TextBoxMode.Password;
- Password.ApplyStyle (_createUserWizard.TextBoxStyle);
-
- Label PasswordLabel = new Label ();
- PasswordLabel.AssociatedControlID = "Password";
- PasswordLabel.Text = _createUserWizard.PasswordLabelText;
-
- RequiredFieldValidator PasswordRequired = new RequiredFieldValidator ();
- PasswordRequired.ID = "PasswordRequired";
- PasswordRequired.ControlToValidate = "Password";
- PasswordRequired.ErrorMessage = _createUserWizard.PasswordRequiredErrorMessage;
- PasswordRequired.ToolTip = _createUserWizard.PasswordRequiredErrorMessage;
- PasswordRequired.Text = "*";
- PasswordRequired.ValidationGroup = _createUserWizard.ID;
- PasswordRequired.ApplyStyle (_createUserWizard.ValidatorTextStyle);
-
- table.Controls.Add (CreateRow (PasswordLabel, Password, PasswordRequired, _createUserWizard.LabelStyle, null));
-
- // Row #4
- if (_createUserWizard.PasswordHintText.Length > 0) {
- table.Controls.Add (
- CreateRow (new LiteralControl (""),
- new LiteralControl (_createUserWizard.PasswordHintText),
- new LiteralControl (""),
- null, _createUserWizard.PasswordHintStyle));
- }
-
- // Row #5
- TextBox ConfirmPassword = new TextBox ();
- ConfirmPassword.ID = "ConfirmPassword";
- ConfirmPassword.TextMode = TextBoxMode.Password;
- ConfirmPassword.ApplyStyle (_createUserWizard.TextBoxStyle);
-
- Label ConfirmPasswordLabel = new Label ();
- ConfirmPasswordLabel.AssociatedControlID = "ConfirmPassword";
- ConfirmPasswordLabel.Text = _createUserWizard.ConfirmPasswordLabelText;
-
- RequiredFieldValidator ConfirmPasswordRequired = new RequiredFieldValidator ();
- ConfirmPasswordRequired.ID = "ConfirmPasswordRequired";
- ConfirmPasswordRequired.ControlToValidate = "ConfirmPassword";
- ConfirmPasswordRequired.ErrorMessage = _createUserWizard.ConfirmPasswordRequiredErrorMessage;
- ConfirmPasswordRequired.ToolTip = _createUserWizard.ConfirmPasswordRequiredErrorMessage;
- ConfirmPasswordRequired.Text = "*";
- ConfirmPasswordRequired.ValidationGroup = _createUserWizard.ID;
- ConfirmPasswordRequired.ApplyStyle (_createUserWizard.ValidatorTextStyle);
-
- table.Controls.Add (CreateRow (ConfirmPasswordLabel, ConfirmPassword, ConfirmPasswordRequired, _createUserWizard.LabelStyle, null));
- }
-
- // Row #6
- if (_createUserWizard.RequireEmail) {
- TextBox Email = new TextBox ();
- Email.ID = "Email";
- Email.ApplyStyle (_createUserWizard.TextBoxStyle);
-
- Label EmailLabel = new Label ();
- EmailLabel.AssociatedControlID = "Email";
- EmailLabel.Text = _createUserWizard.EmailLabelText;
-
- RequiredFieldValidator EmailRequired = new RequiredFieldValidator ();
- EmailRequired.ID = "EmailRequired";
- EmailRequired.ControlToValidate = "Email";
- EmailRequired.ErrorMessage = _createUserWizard.EmailRequiredErrorMessage;
- EmailRequired.ToolTip = _createUserWizard.EmailRequiredErrorMessage;
- EmailRequired.Text = "*";
- EmailRequired.ValidationGroup = _createUserWizard.ID;
- EmailRequired.ApplyStyle (_createUserWizard.ValidatorTextStyle);
-
- table.Controls.Add (CreateRow (EmailLabel, Email, EmailRequired, _createUserWizard.LabelStyle, null));
- }
-
- // Row #7
- if (_createUserWizard.QuestionAndAnswerRequired) {
- TextBox Question = new TextBox ();
- Question.ID = "Question";
- Question.ApplyStyle (_createUserWizard.TextBoxStyle);
-
- Label QuestionLabel = new Label ();
- QuestionLabel.AssociatedControlID = "Question";
- QuestionLabel.Text = _createUserWizard.QuestionLabelText;
-
- RequiredFieldValidator QuestionRequired = new RequiredFieldValidator ();
- QuestionRequired.ID = "QuestionRequired";
- QuestionRequired.ControlToValidate = "Question";
- QuestionRequired.ErrorMessage = _createUserWizard.QuestionRequiredErrorMessage;
- QuestionRequired.ToolTip = _createUserWizard.QuestionRequiredErrorMessage;
- QuestionRequired.Text = "*";
- QuestionRequired.ValidationGroup = _createUserWizard.ID;
- QuestionRequired.ApplyStyle (_createUserWizard.ValidatorTextStyle);
-
- table.Controls.Add (CreateRow (QuestionLabel, Question, QuestionRequired, _createUserWizard.LabelStyle, null));
-
- // Row #8
- TextBox Answer = new TextBox ();
- Answer.ID = "Answer";
- Answer.ApplyStyle (_createUserWizard.TextBoxStyle);
-
- Label AnswerLabel = new Label ();
- AnswerLabel.AssociatedControlID = "Answer";
- AnswerLabel.Text = _createUserWizard.AnswerLabelText;
-
- RequiredFieldValidator AnswerRequired = new RequiredFieldValidator ();
- AnswerRequired.ID = "AnswerRequired";
- AnswerRequired.ControlToValidate = "Answer";
- AnswerRequired.ErrorMessage = _createUserWizard.AnswerRequiredErrorMessage;
- AnswerRequired.ToolTip = _createUserWizard.AnswerRequiredErrorMessage;
- AnswerRequired.Text = "*";
- AnswerRequired.ValidationGroup = _createUserWizard.ID;
- AnswerRequired.ApplyStyle (_createUserWizard.ValidatorTextStyle);
-
- table.Controls.Add (CreateRow (AnswerLabel, Answer, AnswerRequired, _createUserWizard.LabelStyle, null));
- }
-
- // Row #9
- if (!_createUserWizard.AutoGeneratePassword) {
- CompareValidator PasswordCompare = new CompareValidator ();
- PasswordCompare.ID = "PasswordCompare";
- PasswordCompare.ControlToCompare = "Password";
- PasswordCompare.ControlToValidate = "ConfirmPassword";
- PasswordCompare.Display = ValidatorDisplay.Static;
- PasswordCompare.ErrorMessage = _createUserWizard.ConfirmPasswordCompareErrorMessage;
- PasswordCompare.ValidationGroup = _createUserWizard.ID;
-
- table.Controls.Add (CreateRow (PasswordCompare, null, null, null, null));
- }
-
- // Row #10
- if (_createUserWizard.PasswordRegularExpression.Length > 0) {
- RegularExpressionValidator PasswordRegEx = new RegularExpressionValidator ();
- PasswordRegEx.ID = "PasswordRegEx";
- PasswordRegEx.ControlToValidate = "Password";
- PasswordRegEx.ValidationExpression = _createUserWizard.PasswordRegularExpression;
- PasswordRegEx.Display = ValidatorDisplay.Static;
- PasswordRegEx.ErrorMessage = _createUserWizard.PasswordRegularExpressionErrorMessage;
- PasswordRegEx.ValidationGroup = _createUserWizard.ID;
-
- table.Controls.Add (CreateRow (PasswordRegEx, null, null, null, null));
- }
-
- // Row #11
- if (_createUserWizard.EmailRegularExpression.Length > 0) {
- RegularExpressionValidator EmailRegEx = new RegularExpressionValidator ();
- EmailRegEx.ID = "EmailRegEx";
- EmailRegEx.ControlToValidate = "Email";
- EmailRegEx.ValidationExpression = _createUserWizard.EmailRegularExpression;
- EmailRegEx.Display = ValidatorDisplay.Static;
- EmailRegEx.ErrorMessage = _createUserWizard.EmailRegularExpressionErrorMessage;
- EmailRegEx.ValidationGroup = _createUserWizard.ID;
-
- table.Controls.Add (CreateRow (EmailRegEx, null, null, null, null));
- }
-
- // Row #12
- Label ErrorMessage = new Label ();
- ErrorMessage.ID = "ErrorMessage";
- ErrorMessage.EnableViewState = false;
- ErrorMessage.ControlStyle.ForeColor = System.Drawing.Color.Red;
-
- table.Controls.Add (CreateRow (ErrorMessage, null, null, null, null));
-
- // Row #13
- TableRow row9 = null;
-
- HyperLink HelpLink = null;
- if (_createUserWizard.HelpPageText.Length > 0) {
- HelpLink = new HyperLink ();
- HelpLink.Text = _createUserWizard.HelpPageText;
-
- if (_createUserWizard.HelpPageUrl.Length > 0)
- HelpLink.NavigateUrl = _createUserWizard.HelpPageUrl;
-
- row9 = CreateRow (HelpLink, null, null, _createUserWizard.HyperLinkStyle, null);
- }
-
- Image HelpPageIcon = null;
- if (_createUserWizard.HelpPageIconUrl.Length > 0) {
- HelpPageIcon = new Image ();
- HelpPageIcon.ImageUrl = _createUserWizard.HelpPageIconUrl;
- HelpPageIcon.BorderWidth = Unit.Pixel (0);
-
- if (_createUserWizard.HelpPageText.Length > 0)
- HelpPageIcon.AlternateText = _createUserWizard.HelpPageText;
-
- if (row9 == null)
- row9 = CreateRow (HelpPageIcon, null, null, _createUserWizard.HyperLinkStyle, null);
- else
- row9.Cells [0].Controls.AddAt (0, HelpPageIcon);
- }
- if (row9 != null) {
- row9.Cells [0].HorizontalAlign = HorizontalAlign.Left;
- table.Controls.Add (row9);
- }
-
- //
- container.Controls.Add (table);
- }
-
- #endregion
- }
-
- sealed class CreateUserStepNavigationTemplate : ITemplate
- {
- readonly CreateUserWizard _createUserWizard;
-
- public CreateUserStepNavigationTemplate (CreateUserWizard createUserWizard)
- {
- _createUserWizard = createUserWizard;
- }
-
- #region ITemplate Members
-
- public void InstantiateIn (Control container)
- {
- Table t = new Table ();
- t.CellPadding = 5;
- t.CellSpacing = 5;
- t.Width = Unit.Percentage (100);
- t.Height = Unit.Percentage (100);
- TableRow row = new TableRow ();
-
- int index = _createUserWizard.WizardSteps.IndexOf (_createUserWizard.CreateUserStep);
- if (index > 0 && _createUserWizard.WizardSteps [index - 1].AllowReturn) {
- Control b = _createUserWizard.CreateButton ("StepPreviousButtonButton", Wizard.MovePreviousCommandName, _createUserWizard.StepPreviousButtonType, _createUserWizard.StepPreviousButtonText, _createUserWizard.StepPreviousButtonImageUrl, _createUserWizard.StepPreviousButtonStyle, true);
- ((IButtonControl) b).CausesValidation = false;
- AddButtonCell (row, b);
- }
- AddButtonCell (row, _createUserWizard.CreateButton ("StepNextButtonButton", Wizard.MoveNextCommandName, _createUserWizard.CreateUserButtonType, _createUserWizard.CreateUserButtonText, _createUserWizard.CreateUserButtonImageUrl, _createUserWizard.CreateUserButtonStyle, true));
- if (_createUserWizard.DisplayCancelButton) {
- Control b = _createUserWizard.CreateButton ("CancelButtonButton", Wizard.CancelCommandName, _createUserWizard.CancelButtonType, _createUserWizard.CancelButtonText, _createUserWizard.CancelButtonImageUrl, _createUserWizard.CancelButtonStyle, true);
- ((IButtonControl) b).CausesValidation = false;
- AddButtonCell (row, b);
- }
- t.Rows.Add (row);
- container.Controls.Add (t);
- }
-
- void AddButtonCell (TableRow row, Control control)
- {
- TableCell cell = new TableCell ();
- cell.HorizontalAlign = HorizontalAlign.Right;
- cell.Controls.Add (control);
- row.Cells.Add (cell);
- }
-
- #endregion
- }
}
#endif
set { base.SkinID = value; }
}
}
-
- internal class BaseWizardContainer : Table, INamingContainer
- {
- internal BaseWizardContainer ()
- {
- SetBindingContainer (false);
- InitTable ();
- }
-
- internal void InstatiateTemplate (ITemplate template)
- {
- TableCell defaultCell = this.Rows [0].Cells [0];
- template.InstantiateIn (defaultCell);
- }
-
- private void InitTable ()
- {
- TableRow row = new TableRow ();
- TableCell cell = new TableCell ();
-
- cell.ControlStyle.Width = Unit.Percentage (100);
- cell.ControlStyle.Height = Unit.Percentage (100);
-
- row.Cells.Add (cell);
-
- this.ControlStyle.Width = Unit.Percentage (100);
- this.ControlStyle.Height = Unit.Percentage (100);
- this.CellPadding = 0;
- this.CellSpacing = 0;
-
- this.Rows.Add (row);
- }
- }
-
- internal class BaseWizardNavigationContainer : Control, INamingContainer
- {
- internal BaseWizardNavigationContainer ()
- {
- SetBindingContainer (false);
- }
- }
}
#endif
int activeStepIndex = -1;
bool inited = false;
- bool dontRender = false;
ArrayList history;
Table wizardTable;
+ WizardHeaderCell _headerCell;
+ TableCell _navigationCell;
+ StartNavigationContainer _startNavContainer;
+ StepNavigationContainer _stepNavContainer;
+ FinishNavigationContainer _finishNavContainer;
MultiView multiView;
DataList stepDatalist;
ArrayList styles = new ArrayList ();
- ArrayList persistStyles = new ArrayList ();
SideBarButtonTemplate sideBarItemTemplate;
Hashtable customNavigation;
if (value < -1 || (value > WizardSteps.Count && (inited || WizardSteps.Count > 0)))
throw new ArgumentOutOfRangeException ("The ActiveStepIndex must be less than WizardSteps.Count and at least -1");
- if (inited && value == -1) {
- dontRender = true;
- activeStepIndex = -1;
- return;
- }
-
if (inited && !AllowNavigationToStep (value))
return;
activeStepIndex = value;
- dontRender = false;
- UpdateControls ();
if (inited) {
+ multiView.ActiveViewIndex = value;
OnActiveStepChanged (this, EventArgs.Empty);
}
}
}
set {
ViewState ["CancelButtonImageUrl"] = value;
- UpdateControls ();
}
}
}
set {
ViewState ["CancelButtonText"] = value;
- UpdateControls ();
}
}
}
set {
ViewState ["CancelButtonType"] = value;
- UpdateControls ();
}
}
[DefaultValueAttribute (0)]
public virtual int CellPadding {
get {
- object v = ViewState ["CellPadding"];
- return v != null ? (int)v : 0;
+ if (ControlStyleCreated)
+ return ((TableStyle) ControlStyle).CellPadding;
+ return 0;
}
set {
- ViewState ["CellPadding"] = value;
- UpdateControls ();
+ ((TableStyle) ControlStyle).CellPadding = value;
}
}
[DefaultValueAttribute (0)]
public virtual int CellSpacing {
get {
- object v = ViewState ["CellSpacing"];
- return v != null ? (int)v : 0;
+ if (ControlStyleCreated)
+ return ((TableStyle) ControlStyle).CellSpacing;
+ return 0;
}
set {
- ViewState ["CellSpacing"] = value;
- UpdateControls ();
+ ((TableStyle) ControlStyle).CellSpacing = value;
}
}
}
set {
ViewState ["DisplayCancelButton"] = value;
- UpdateControls ();
}
}
}
set {
ViewState ["DisplaySideBar"] = value;
- UpdateControls ();
+ UpdateViews ();
}
}
}
set {
ViewState ["FinishCompleteButtonImageUrl"] = value;
- UpdateControls ();
}
}
}
set {
ViewState ["FinishCompleteButtonText"] = value;
- UpdateControls ();
}
}
}
set {
ViewState ["FinishCompleteButtonType"] = value;
- UpdateControls ();
}
}
[Browsable (false)]
public virtual ITemplate FinishNavigationTemplate {
get { return finishNavigationTemplate; }
- set { finishNavigationTemplate = value; UpdateControls (); }
+ set { finishNavigationTemplate = value; UpdateViews (); }
}
[UrlPropertyAttribute]
}
set {
ViewState ["FinishPreviousButtonImageUrl"] = value;
- UpdateControls ();
}
}
}
set {
ViewState ["FinishPreviousButtonText"] = value;
- UpdateControls ();
}
}
}
set {
ViewState ["FinishPreviousButtonType"] = value;
- UpdateControls ();
}
}
[Browsable (false)]
public virtual ITemplate HeaderTemplate {
get { return headerTemplate; }
- set { headerTemplate = value; UpdateControls (); }
+ set { headerTemplate = value; UpdateViews (); }
}
[DefaultValueAttribute ("")]
}
set {
ViewState ["HeaderText"] = value;
- UpdateControls ();
}
}
[Browsable (false)]
public virtual ITemplate SideBarTemplate {
get { return sideBarTemplate; }
- set { sideBarTemplate = value; UpdateControls (); }
+ set { sideBarTemplate = value; UpdateViews (); }
}
[Localizable (true)]
[Browsable (false)]
public virtual ITemplate StartNavigationTemplate {
get { return startNavigationTemplate; }
- set { startNavigationTemplate = value; UpdateControls (); }
+ set { startNavigationTemplate = value; UpdateViews (); }
}
[UrlPropertyAttribute]
}
set {
ViewState ["StartNextButtonImageUrl"] = value;
- UpdateControls ();
}
}
}
set {
ViewState ["StartNextButtonText"] = value;
- UpdateControls ();
}
}
}
set {
ViewState ["StartNextButtonType"] = value;
- UpdateControls ();
}
}
[Browsable (false)]
public virtual ITemplate StepNavigationTemplate {
get { return stepNavigationTemplate; }
- set { stepNavigationTemplate = value; UpdateControls (); }
+ set { stepNavigationTemplate = value; UpdateViews (); }
}
[UrlPropertyAttribute]
}
set {
ViewState ["StepNextButtonImageUrl"] = value;
- UpdateControls ();
}
}
}
set {
ViewState ["StepNextButtonText"] = value;
- UpdateControls ();
}
}
}
set {
ViewState ["StepNextButtonType"] = value;
- UpdateControls ();
}
}
}
set {
ViewState ["StepPreviousButtonImageUrl"] = value;
- UpdateControls ();
}
}
}
set {
ViewState ["StepPreviousButtonText"] = value;
- UpdateControls ();
}
}
}
set {
ViewState ["StepPreviousButtonType"] = value;
- UpdateControls ();
}
}
protected internal override void OnInit (EventArgs e)
{
- inited = true;
-
Page.RegisterRequiresControlState (this);
base.OnInit (e);
+
+ if (ActiveStepIndex == -1)
+ ActiveStepIndex = 0;
+
+ EnsureChildControls ();
+
+ inited = true;
}
protected override ControlCollection CreateControlCollection ()
TableRow viewRow = new TableRow ();
TableCell viewCell = new TableCell ();
- if (multiView == null)
- {
- persistStyles.Clear ();
- customNavigation = null;
- multiView = new MultiView();
- foreach (View v in WizardSteps) {
- if (v is TemplatedWizardStep)
- InstantiateTemplateStep ((TemplatedWizardStep) v);
- multiView.Views.Add (v);
- }
+ customNavigation = null;
+ multiView = new MultiView ();
+ foreach (View v in WizardSteps) {
+ if (v is TemplatedWizardStep)
+ InstantiateTemplateStep ((TemplatedWizardStep) v);
+ multiView.Views.Add (v);
}
-
- if (ActiveStepIndex == -1 && !dontRender)
- ActiveStepIndex = 0;
-
multiView.ActiveViewIndex = ActiveStepIndex;
- if (ActiveStepIndex >= 0) {
RegisterApplyStyle (viewCell, StepStyle);
viewCell.Controls.Add (multiView);
viewRow.Cells.Add (viewCell);
wizardTable.Rows.Add (viewRow);
TableRow buttonRow = new TableRow ();
- TableCell buttonCell = new TableCell ();
- buttonCell.HorizontalAlign = HorizontalAlign.Right;
- RegisterApplyStyle (buttonCell, NavigationStyle);
- if (CreateButtonBar (buttonCell)) {
- buttonRow.Cells.Add (buttonCell);
- wizardTable.Rows.Add (buttonRow);
- }
+ _navigationCell = new TableCell ();
+ _navigationCell .HorizontalAlign = HorizontalAlign.Right;
+ RegisterApplyStyle (_navigationCell, NavigationStyle);
+ CreateButtonBar (_navigationCell);
+ buttonRow.Cells.Add (_navigationCell);
+ wizardTable.Rows.Add (buttonRow);
- if (DisplaySideBar && ActiveStep.StepType != WizardStepType.Complete) {
+ if (DisplaySideBar) {
Table contentTable = wizardTable;
contentTable.Height = new Unit ("100%");
contentTable.Width = new Unit ("100%");
wizardTable.Rows.Add (row);
}
- }
Controls.SetReadonly (false);
Controls.Add (wizardTable);
BaseWizardContainer contentTemplateContainer = new BaseWizardContainer ();
if (step.ContentTemplate != null)
- contentTemplateContainer.InstatiateTemplate (step.ContentTemplate);
+ step.ContentTemplate.InstantiateIn (contentTemplateContainer.InnerCell);
step.ContentTemplateContainer = contentTemplateContainer;
step.Controls.Clear ();
customNavigation [step] = customNavigationTemplateContainer;
}
- bool CreateButtonBar (TableCell buttonBarCell)
+ void CreateButtonBar (TableCell buttonBarCell)
{
- if(customNavigation!=null && customNavigation [ActiveStep]!=null) {
- Control customNavigationTemplateContainer = (Control) customNavigation [ActiveStep];
- customNavigationTemplateContainer.ID = "CustomNavContainer";
- buttonBarCell.Controls.Add (customNavigationTemplateContainer);
- return true;
+ if(customNavigation!=null && customNavigation.Values.Count>0)
+ {
+ int i = 0;
+ foreach (Control customNavigationTemplateContainer in customNavigation.Values) {
+ customNavigationTemplateContainer.ID = "CustomNavContainer" + i++;
+ buttonBarCell.Controls.Add (customNavigationTemplateContainer);
+ }
}
+ //
+ // StartNavContainer
+ //
+ _startNavContainer = new StartNavigationContainer (this);
+ _startNavContainer.ID = "StartNavContainer";
+ if (startNavigationTemplate != null) {
+ AddTemplateButtonBar (_startNavContainer, startNavigationTemplate, StartNextButtonID, CancelButtonID);
+ }
+ else {
+ TableRow row;
+ AddNavButtonsTable (_startNavContainer, out row);
+ AddButtonCell (row, CreateButtonSet (StartNextButtonID, MoveNextCommandName));
+ AddButtonCell (row, CreateButtonSet (CancelButtonID, CancelCommandName));
+ _startNavContainer.ConfirmDefaultTemplate ();
+ }
+ buttonBarCell.Controls.Add (_startNavContainer);
+
+ //
+ // StepNavContainer
+ //
+ _stepNavContainer = new StepNavigationContainer (this);
+ _stepNavContainer.ID = "StepNavContainer";
+ if (stepNavigationTemplate != null) {
+ AddTemplateButtonBar (_stepNavContainer, stepNavigationTemplate, StepPreviousButtonID, StepNextButtonID, CancelButtonID);
+ }
+ else {
+ TableRow row;
+ AddNavButtonsTable (_stepNavContainer, out row);
+ AddButtonCell (row, CreateButtonSet (StepPreviousButtonID, MovePreviousCommandName));
+ AddButtonCell (row, CreateButtonSet (StepNextButtonID, MoveNextCommandName));
+ AddButtonCell (row, CreateButtonSet (CancelButtonID, CancelCommandName));
+ _stepNavContainer.ConfirmDefaultTemplate ();
+ }
+ buttonBarCell.Controls.Add (_stepNavContainer);
+
+ //
+ // StepNavContainer
+ //
+ _finishNavContainer = new FinishNavigationContainer (this);
+ _finishNavContainer.ID = "FinishNavContainer";
+ if (finishNavigationTemplate != null) {
+ AddTemplateButtonBar (_finishNavContainer, finishNavigationTemplate, FinishPreviousButtonID, FinishButtonID, CancelButtonID);
+ }
+ else {
+ TableRow row;
+ AddNavButtonsTable (_finishNavContainer, out row);
+ AddButtonCell (row, CreateButtonSet (FinishPreviousButtonID, MovePreviousCommandName));
+ AddButtonCell (row, CreateButtonSet (FinishButtonID, MoveCompleteCommandName));
+ AddButtonCell (row, CreateButtonSet (CancelButtonID, CancelCommandName));
+ _finishNavContainer.ConfirmDefaultTemplate ();
+ }
+ buttonBarCell.Controls.Add (_finishNavContainer);
+ }
+
+ private static void AddNavButtonsTable (BaseWizardNavigationContainer container, out TableRow row)
+ {
Table t = new Table ();
t.CellPadding = 5;
t.CellSpacing = 5;
- TableRow row = new TableRow ();
-
- WizardStepType stepType = GetStepType (ActiveStep, ActiveStepIndex);
- switch (stepType) {
- case WizardStepType.Start:
- if (startNavigationTemplate != null) {
- AddTemplateButtonBar (buttonBarCell, startNavigationTemplate, StartNextButtonID, CancelButtonID);
- return true;
- } else {
- if (AllowNavigationToStep (ActiveStepIndex + 1))
- AddButtonCell (row, CreateButton (StartNextButtonID, MoveNextCommandName, StartNextButtonType, StartNextButtonText, StartNextButtonImageUrl, StartNextButtonStyle));
- if (DisplayCancelButton)
- AddButtonCell (row, CreateButton (CancelButtonID, CancelCommandName, CancelButtonType, CancelButtonText, CancelButtonImageUrl, CancelButtonStyle));
- }
- break;
- case WizardStepType.Step:
- if (stepNavigationTemplate != null) {
- AddTemplateButtonBar (buttonBarCell, stepNavigationTemplate, StepPreviousButtonID, StepNextButtonID, CancelButtonID);
- return true;
- } else {
- if (AllowNavigationToStep (ActiveStepIndex - 1))
- AddButtonCell (row, CreateButton (StepPreviousButtonID, MovePreviousCommandName, StepPreviousButtonType, StepPreviousButtonText, StepPreviousButtonImageUrl, StepPreviousButtonStyle));
- if (AllowNavigationToStep (ActiveStepIndex + 1))
- AddButtonCell (row, CreateButton (StepNextButtonID, MoveNextCommandName, StepNextButtonType, StepNextButtonText, StepNextButtonImageUrl, StepNextButtonStyle));
- if (DisplayCancelButton)
- AddButtonCell (row, CreateButton (CancelButtonID, CancelCommandName, CancelButtonType, CancelButtonText, CancelButtonImageUrl, CancelButtonStyle));
- }
- break;
- case WizardStepType.Finish:
- if (finishNavigationTemplate != null) {
- AddTemplateButtonBar (buttonBarCell, finishNavigationTemplate, FinishPreviousButtonID, FinishButtonID, CancelButtonID);
- return true;
- } else {
- if (AllowNavigationToStep (ActiveStepIndex - 1))
- AddButtonCell (row, CreateButton (FinishPreviousButtonID, MovePreviousCommandName, FinishPreviousButtonType, FinishPreviousButtonText, FinishPreviousButtonImageUrl, FinishPreviousButtonStyle));
- AddButtonCell (row, CreateButton (FinishButtonID, MoveCompleteCommandName, FinishCompleteButtonType, FinishCompleteButtonText, FinishCompleteButtonImageUrl, FinishCompleteButtonStyle));
- if (DisplayCancelButton)
- AddButtonCell (row, CreateButton (CancelButtonID, CancelCommandName, CancelButtonType, CancelButtonText, CancelButtonImageUrl, CancelButtonStyle));
- }
- break;
- }
-
- if (row.Cells.Count == 0)
- return false;
-
+ row = new TableRow ();
t.Rows.Add (row);
- buttonBarCell.Controls.Add (t);
-
- return true;
+ container.Controls.Add (t);
+ }
+
+ internal Control [] CreateButtonSet (string id, string command)
+ {
+ return CreateButtonSet (id, command, true);
}
- Control CreateButton (string id, string command, ButtonType type, string text, string image, Style style)
+ internal Control [] CreateButtonSet (string id, string command, bool causesValidation)
{
- return CreateButton (id, command, type, text, image, style, false);
+ return new Control [] {
+ CreateButton ( id + ButtonType.Button, command, ButtonType.Button, causesValidation),
+ CreateButton ( id + ButtonType.Image, command, ButtonType.Image, causesValidation),
+ CreateButton ( id + ButtonType.Link, command, ButtonType.Link, causesValidation)
+ };
}
- internal Control CreateButton (string id, string command, ButtonType type, string text, string image, Style style, bool persistStyle)
+ Control CreateButton (string id, string command, ButtonType type, bool causesValidation)
{
WebControl b;
switch (type) {
b = CreateStandartButton ();
break;
case ButtonType.Image:
- b = CreateImageButton (image);
+ b = CreateImageButton (null);
break;
case ButtonType.Link:
b = CreateLinkButton ();
default:
throw new ArgumentOutOfRangeException ("type");
}
-
+
b.ID = id;
b.EnableTheming = false;
((IButtonControl) b).CommandName = command;
- ((IButtonControl) b).Text = text;
((IButtonControl) b).ValidationGroup = ID;
+ ((IButtonControl) b).CausesValidation = causesValidation;
+
+ RegisterApplyStyle (b, NavigationButtonStyle);
- RegisterApplyStyle (b, NavigationButtonStyle, persistStyle);
- RegisterApplyStyle (b, style, persistStyle);
return b;
}
return link;
}
- void AddTemplateButtonBar (TableCell cell, ITemplate template, params string[] buttonIds)
+ void AddTemplateButtonBar (BaseWizardNavigationContainer container, ITemplate template, params string [] buttonIds)
{
- BaseWizardNavigationContainer container = new BaseWizardNavigationContainer ();
- container.ID = "WizardNavContainer";
- cell.Controls.Add (container);
template.InstantiateIn (container);
foreach (string id in buttonIds) {
if (b != null) RegisterCommandEvents (b);
}
}
-
- void AddButtonCell (TableRow row, Control control)
+
+ void AddButtonCell (TableRow row, params Control[] controls)
{
TableCell cell = new TableCell ();
cell.HorizontalAlign = HorizontalAlign.Right;
- cell.Controls.Add (control);
+ for (int i = 0; i < controls.Length; i++)
+ cell.Controls.Add (controls [i]);
row.Cells.Add (cell);
}
button.Text = step.Name;
}
}
-
+
void AddHeaderRow (Table table)
{
- if (HeaderText.Length != 0 || headerTemplate != null) {
- TableRow row = new TableRow ();
- TableCell cell = new TableCell ();
- RegisterApplyStyle (cell, HeaderStyle);
- if (headerTemplate != null)
- headerTemplate.InstantiateIn (cell);
- else
- cell.Text = HeaderText;
- row.Cells.Add (cell);
- table.Rows.Add (row);
+ TableRow row = new TableRow ();
+ _headerCell = new WizardHeaderCell ();
+ RegisterApplyStyle (_headerCell, HeaderStyle);
+ if (headerTemplate != null) {
+ headerTemplate.InstantiateIn (_headerCell);
+ _headerCell.ConfirmInitState ();
}
+ row.Cells.Add (_headerCell);
+ table.Rows.Add (row);
}
- void RegisterApplyStyle (WebControl control, Style style)
- {
- RegisterApplyStyle (control, style, false);
- }
-
- internal void RegisterApplyStyle (WebControl control, Style style, bool persistStyle)
+ internal void RegisterApplyStyle (WebControl control, Style style)
{
- if (persistStyle)
- persistStyles.Add (new object [] { control, style });
- else
- styles.Add (new object [] { control, style });
+ styles.Add (new object [] { control, style });
}
protected override Style CreateControlStyle ()
if (states[9] != null) ((IStateManager)StartNextButtonStyle).LoadViewState (states[9]);
if (states[10] != null) ((IStateManager)StepNextButtonStyle).LoadViewState (states[10]);
if (states[11] != null) ((IStateManager)StepPreviousButtonStyle).LoadViewState (states[11]);
- if (states[12] != null) ((IStateManager)NavigationButtonStyle).LoadViewState (states[12]);\r
- if (states [13] != null)\r
- ControlStyle.LoadViewState (states [13]);\r
+ if (states[12] != null) ((IStateManager)NavigationButtonStyle).LoadViewState (states[12]);
+ if (states [13] != null)
+ ControlStyle.LoadViewState (states [13]);
}
protected override object SaveViewState ()
if (startNextButtonStyle != null) state [9] = ((IStateManager)startNextButtonStyle).SaveViewState ();
if (stepNextButtonStyle != null) state [10] = ((IStateManager)stepNextButtonStyle).SaveViewState ();
if (stepPreviousButtonStyle != null) state [11] = ((IStateManager)stepPreviousButtonStyle).SaveViewState ();
- if (navigationButtonStyle != null) state [12] = ((IStateManager)navigationButtonStyle).SaveViewState ();\r
- if (ControlStyleCreated)\r
- state [13] = ControlStyle.SaveViewState ();\r
+ if (navigationButtonStyle != null) state [12] = ((IStateManager)navigationButtonStyle).SaveViewState ();
+ if (ControlStyleCreated)
+ state [13] = ControlStyle.SaveViewState ();
for (int n=0; n<state.Length; n++)
if (state [n] != null) return state;
if (startNextButtonStyle != null) ((IStateManager)startNextButtonStyle).TrackViewState();
if (stepNextButtonStyle != null) ((IStateManager)stepNextButtonStyle).TrackViewState();
if (stepPreviousButtonStyle != null) ((IStateManager)stepPreviousButtonStyle).TrackViewState();
- if (navigationButtonStyle != null) ((IStateManager)navigationButtonStyle).TrackViewState();\r
- if (ControlStyleCreated)\r
- ControlStyle.TrackViewState ();\r
+ if (navigationButtonStyle != null) ((IStateManager)navigationButtonStyle).TrackViewState();
+ if (ControlStyleCreated)
+ ControlStyle.TrackViewState ();
}
protected internal void RegisterCommandEvents (IButtonControl button)
}
}
- void UpdateControls ()
+ internal void UpdateViews ()
{
ChildControlsCreated = false;
}
- internal void UpdateViews ()
+ protected internal override void Render (HtmlTextWriter writer)
{
- multiView = null;
- UpdateControls ();
+ PrepareControlHierarchy ();
+
+ wizardTable.Render (writer);
}
-
- protected internal override void Render (HtmlTextWriter writer)
+
+ void PrepareControlHierarchy ()
{
wizardTable.ApplyStyle (ControlStyle);
- foreach (object[] styleDef in styles)
- ((WebControl)styleDef[0]).ApplyStyle ((Style)styleDef[1]);
-
- foreach (object [] styleDef in persistStyles)
+ foreach (object [] styleDef in styles)
((WebControl) styleDef [0]).ApplyStyle ((Style) styleDef [1]);
-
- wizardTable.Render (writer);
+
+ // header
+ if (!_headerCell.Initialized) {
+ if (String.IsNullOrEmpty (HeaderText))
+ _headerCell.Parent.Visible = false;
+ else
+ _headerCell.Text = HeaderText;
+ }
+
+ // content
+ TemplatedWizardStep templateStep = ActiveStep as TemplatedWizardStep;
+ if (templateStep != null) {
+ BaseWizardContainer contentContainer = templateStep.ContentTemplateContainer as BaseWizardContainer;
+ if (contentContainer != null)
+ contentContainer.PrepareControlHierarchy ();
+ }
+
+ // navigation
+ if (customNavigation != null) {
+ foreach (Control c in customNavigation.Values)
+ c.Visible = false;
+ }
+ _startNavContainer.Visible = false;
+ _stepNavContainer.Visible = false;
+ _finishNavContainer.Visible = false;
+
+ BaseWizardNavigationContainer currentNavContainer = GetCurrentNavContainer ();
+ if (currentNavContainer == null) {
+ _navigationCell.Parent.Visible = false;
+ }
+ else {
+ currentNavContainer.Visible = true;
+ currentNavContainer.PrepareControlHierarchy ();
+ if (!currentNavContainer.Visible)
+ _navigationCell.Parent.Visible = false;
+ }
+ }
+
+ private BaseWizardNavigationContainer GetCurrentNavContainer ()
+ {
+ if (customNavigation != null && customNavigation [ActiveStep] != null) {
+ return (BaseWizardNavigationContainer) customNavigation [ActiveStep];
+ }
+ else {
+ WizardStepType stepType = GetStepType (ActiveStep, ActiveStepIndex);
+ switch (stepType) {
+ case WizardStepType.Start:
+ return _startNavContainer;
+ case WizardStepType.Step:
+ return _stepNavContainer;
+ case WizardStepType.Finish:
+ return _finishNavContainer;
+ default:
+ return null;
+ }
+ }
}
class TableCellNamingContainer : TableCell, INamingContainer
}
}
}
+
+ class WizardHeaderCell : TableCell
+ {
+ bool _initialized;
+
+ public bool Initialized {
+ get { return _initialized; }
+ }
+
+ public void ConfirmInitState ()
+ {
+ _initialized = true;
+ }
+ }
+
+ internal abstract class DefaultNavigationContainer : BaseWizardNavigationContainer
+ {
+ bool _isDefault;
+ Wizard _wizard;
+
+ protected Wizard Wizard {
+ get { return _wizard; }
+ }
+
+ protected DefaultNavigationContainer (Wizard wizard)
+ {
+ _wizard = wizard;
+ }
+
+ public override sealed void PrepareControlHierarchy ()
+ {
+ if (_isDefault)
+ UpdateState ();
+ }
+
+ protected abstract void UpdateState ();
+
+ public void ConfirmDefaultTemplate ()
+ {
+ _isDefault = true;
+ }
+
+ protected void UpdateNavButtonState (string id, string text, string image, Style style)
+ {
+ WebControl b = (WebControl) FindControl (id);
+ foreach (Control c in b.Parent.Controls)
+ c.Visible = b == c;
+
+ ((IButtonControl) b).Text = text;
+ ImageButton imgbtn = b as ImageButton;
+ if (imgbtn != null)
+ imgbtn.ImageUrl = image;
+
+ b.ApplyStyle (style);
+ }
+ }
+
+ sealed class StartNavigationContainer : DefaultNavigationContainer
+ {
+ public StartNavigationContainer (Wizard wizard)
+ : base (wizard)
+ {
+ }
+
+ protected override void UpdateState ()
+ {
+ bool visible = false;
+
+ // next
+ if (Wizard.AllowNavigationToStep (Wizard.ActiveStepIndex + 1)) {
+ visible = true;
+ UpdateNavButtonState (Wizard.StartNextButtonID + Wizard.StartNextButtonType, Wizard.StartNextButtonText, Wizard.StartNextButtonImageUrl, Wizard.StartNextButtonStyle);
+ }
+ else {
+ ((Table) Controls [0]).Rows [0].Cells [0].Visible = false;
+ }
+
+ // cancel
+ if (Wizard.DisplayCancelButton) {
+ visible = true;
+ UpdateNavButtonState (Wizard.CancelButtonID + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
+ }
+ else {
+ ((Table) Controls [0]).Rows [0].Cells [1].Visible = false;
+ }
+ Visible = visible;
+ }
+ }
+
+ sealed class StepNavigationContainer : DefaultNavigationContainer
+ {
+ public StepNavigationContainer (Wizard wizard)
+ : base (wizard)
+ {
+ }
+
+ protected override void UpdateState ()
+ {
+ bool visible = false;
+
+ // previous
+ if (Wizard.AllowNavigationToStep (Wizard.ActiveStepIndex - 1)) {
+ visible = true;
+ UpdateNavButtonState (Wizard.StepPreviousButtonID + Wizard.StepPreviousButtonType, Wizard.StepPreviousButtonText, Wizard.StepPreviousButtonImageUrl, Wizard.StepPreviousButtonStyle);
+ }
+ else {
+ ((Table) Controls [0]).Rows [0].Cells [0].Visible = false;
+ }
+
+ // next
+ if (Wizard.AllowNavigationToStep (Wizard.ActiveStepIndex + 1)) {
+ visible = true;
+ UpdateNavButtonState (Wizard.StepNextButtonID + Wizard.StepNextButtonType, Wizard.StepNextButtonText, Wizard.StepNextButtonImageUrl, Wizard.StepNextButtonStyle);
+ }
+ else {
+ ((Table) Controls [0]).Rows [0].Cells [1].Visible = false;
+ }
+
+ // cancel
+ if (Wizard.DisplayCancelButton) {
+ visible = true;
+ UpdateNavButtonState (Wizard.CancelButtonID + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
+ }
+ else {
+ ((Table) Controls [0]).Rows [0].Cells [2].Visible = false;
+ }
+ Visible = visible;
+ }
+ }
+
+ sealed class FinishNavigationContainer : DefaultNavigationContainer
+ {
+ public FinishNavigationContainer (Wizard wizard)
+ : base (wizard)
+ {
+ }
+
+ protected override void UpdateState ()
+ {
+ // previous
+ if (Wizard.AllowNavigationToStep (Wizard.ActiveStepIndex - 1)) {
+ UpdateNavButtonState (Wizard.FinishPreviousButtonID + Wizard.FinishPreviousButtonType, Wizard.FinishPreviousButtonText, Wizard.FinishPreviousButtonImageUrl, Wizard.FinishPreviousButtonStyle);
+ }
+ else {
+ ((Table) Controls [0]).Rows [0].Cells [0].Visible = false;
+ }
+
+ // finish
+ UpdateNavButtonState (Wizard.FinishButtonID + Wizard.FinishCompleteButtonType, Wizard.FinishCompleteButtonText, Wizard.FinishCompleteButtonImageUrl, Wizard.FinishCompleteButtonStyle);
+
+ // cancel
+ if (Wizard.DisplayCancelButton) {
+ UpdateNavButtonState (Wizard.CancelButtonID + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
+ }
+ else {
+ ((Table) Controls [0]).Rows [0].Cells [2].Visible = false;
+ }
+ }
+ }
+
+ internal class BaseWizardContainer : Table, INamingContainer
+ {
+ public TableCell InnerCell {
+ get { return Rows [0].Cells [0]; }
+ }
+
+ internal BaseWizardContainer ()
+ {
+ SetBindingContainer (false);
+ InitTable ();
+ }
+
+ private void InitTable () {
+ TableRow row = new TableRow ();
+ TableCell cell = new TableCell ();
+
+ cell.ControlStyle.Width = Unit.Percentage (100);
+ cell.ControlStyle.Height = Unit.Percentage (100);
+
+ row.Cells.Add (cell);
+
+ this.ControlStyle.Width = Unit.Percentage (100);
+ this.ControlStyle.Height = Unit.Percentage (100);
+ this.CellPadding = 0;
+ this.CellSpacing = 0;
+
+ this.Rows.Add (row);
+ }
+
+ public virtual void PrepareControlHierarchy ()
+ {
+ }
+ }
+
+ internal class BaseWizardNavigationContainer : Control, INamingContainer
+ {
+ internal BaseWizardNavigationContainer ()
+ {
+ SetBindingContainer (false);
+ }
+
+ public virtual void PrepareControlHierarchy ()
+ {
+ }
+ }
+
+ internal abstract class DefaultContentContainer : BaseWizardContainer
+ {
+ bool _isDefault;
+ Wizard _wizard;
+
+ protected bool IsDefaultTemplate {
+ get { return _isDefault; }
+ }
+
+ protected Wizard Wizard {
+ get { return _wizard; }
+ }
+
+ protected DefaultContentContainer (Wizard wizard)
+ {
+ _wizard = wizard;
+ }
+
+ public override sealed void PrepareControlHierarchy ()
+ {
+ if (_isDefault)
+ UpdateState ();
+ }
+
+ protected abstract void UpdateState ();
+
+ public void ConfirmDefaultTemplate ()
+ {
+ _isDefault = true;
+ }
+ }
}
}
// ValidatorTextStyle
// ErrorMessageStyle
[Test]
- [Category ("NotWorking")]
[Category ("NunitWeb")]
public void CreateUserTest ()
{
[Test]
[Category ("NunitWeb")]
- [Category ("NotWorking")]
public void WizardStepBase_Theme ()
{
-#if DOT_NET
+#if VISUAL_STUDIO
WebTest.CopyResource (GetType (), "MonoTests.System.Web.UI.WebControls.Resources.WizardTest.skin", "App_Themes/Theme1/WizardTest.skin");
#else
WebTest.CopyResource (GetType (), "WizardTest.skin", "App_Themes/Theme1/WizardTest.skin");
[TestFixture]
public class WizardTest
{
-
- [SetUp]
- public void SetupTestCase ()
- {
- Thread.Sleep (100);
- }
-
[Test]
public void Wizard_DefaultProperty ()
{
w.ActiveStepIndex = (int) WebTest.CurrentTest.UserData;
p.Controls.Add (w);
- }\r
-\r
- [Test]\r
- [Category ("NotWorking")] // implementation details\r
- [Category ("NunitWeb")]\r
- public void Wizard_PostBackFireEvents_1 ()\r
- {\r
- WebTest t = new WebTest ();\r
- PageDelegates pd = new PageDelegates ();\r
- pd.PreInit = _postbackEvents;\r
- t.Invoker = new PageInvoker (pd);\r
- t.Run ();\r
- FormRequest fr = new FormRequest (t.Response, "form1");\r
-\r
- //Cancel\r
- fr.Controls.Add ("__EVENTTARGET");\r
- fr.Controls.Add ("__EVENTARGUMENT");\r
- fr.Controls.Add ("Wizard1$StartNavigationTemplateContainerID$CancelButton");\r
- fr.Controls["__EVENTTARGET"].Value = "";\r
- fr.Controls["__EVENTARGUMENT"].Value = "";\r
- fr.Controls["Wizard1$StartNavigationTemplateContainerID$CancelButton"].Value = "Cancel";\r
- t.Request = fr;\r
- t.Run ();\r
- Assert.AreEqual ("CancelButtonClick", t.UserData.ToString (), "Cancel");\r
- \r
- // Next\r
- fr.Controls.Add ("__EVENTTARGET");\r
- fr.Controls.Add ("__EVENTARGUMENT");\r
- fr.Controls.Add ("Wizard1$StartNavigationTemplateContainerID$StartNextButton");\r
- fr.Controls["__EVENTTARGET"].Value = "";\r
- fr.Controls["__EVENTARGUMENT"].Value = "";\r
- fr.Controls["Wizard1$StartNavigationTemplateContainerID$StartNextButton"].Value = "Next";\r
- t.Request = fr;\r
- t.Run ();\r
- Assert.AreEqual ("NextButtonClick", t.UserData.ToString (), "Next");\r
-\r
- // Previous\r
- fr = new FormRequest (t.Response, "form1");\r
- fr.Controls.Add ("__EVENTTARGET");\r
- fr.Controls.Add ("__EVENTARGUMENT");\r
- fr.Controls.Add ("Wizard1$FinishNavigationTemplateContainerID$FinishPreviousButton");\r
-\r
- fr.Controls["__EVENTTARGET"].Value = "";\r
- fr.Controls["__EVENTARGUMENT"].Value = "";\r
- fr.Controls["Wizard1$FinishNavigationTemplateContainerID$FinishPreviousButton"].Value = "Previous";\r
- t.Request = fr;\r
- t.Run ();\r
- Assert.AreEqual ("PreviousButtonClick", t.UserData.ToString (), "Previous");\r
-\r
- //SideBarButton\r
- fr = new FormRequest (t.Response, "form1");\r
- fr.Controls.Add ("__EVENTTARGET");\r
- fr.Controls.Add ("__EVENTARGUMENT");\r
-\r
- fr.Controls["__EVENTTARGET"].Value = "Wizard1$SideBarContainer$SideBarList$ctl01$SideBarButton";\r
- fr.Controls["__EVENTARGUMENT"].Value = "";\r
- t.Request = fr;\r
- t.Run ();\r
- Assert.AreEqual ("SideBarButtonClick", t.UserData.ToString (), "SideBarButton");\r
- \r
- }\r
-\r
- [Test]\r
- [Category ("NunitWeb")]\r
- [Category ("NotWorking")] // implementation details\r
- public void Wizard_PostBackFireEvents_2 ()\r
- {\r
- WebTest t = new WebTest ();\r
- PageDelegates pd = new PageDelegates ();\r
- pd.PreInit = _postbackEvents;\r
- t.Invoker = new PageInvoker (pd);\r
- t.Run ();\r
- FormRequest fr = new FormRequest (t.Response, "form1");\r
-\r
- // Next\r
- fr.Controls.Add ("__EVENTTARGET");\r
- fr.Controls.Add ("__EVENTARGUMENT");\r
- fr.Controls.Add ("Wizard1$StartNavigationTemplateContainerID$StartNextButton");\r
- fr.Controls["__EVENTTARGET"].Value = "";\r
- fr.Controls["__EVENTARGUMENT"].Value = "";\r
- fr.Controls["Wizard1$StartNavigationTemplateContainerID$StartNextButton"].Value = "Next";\r
- t.Request = fr;\r
- t.Run ();\r
- Assert.AreEqual ("NextButtonClick", t.UserData.ToString (), "Next");\r
-\r
- // Finish\r
- fr = new FormRequest (t.Response, "form1");\r
- fr.Controls.Add ("__EVENTTARGET");\r
- fr.Controls.Add ("__EVENTARGUMENT");\r
- fr.Controls.Add ("Wizard1$FinishNavigationTemplateContainerID$FinishButton");\r
- fr.Controls["__EVENTTARGET"].Value = "";\r
- fr.Controls["__EVENTARGUMENT"].Value = "";\r
- fr.Controls["Wizard1$FinishNavigationTemplateContainerID$FinishButton"].Value = "Finish";\r
- t.Request = fr;\r
- t.Run ();\r
- Assert.AreEqual ("FinishButtonClick", t.UserData.ToString (), "Finish");\r
-\r
- }\r
-\r
- public static void _postbackEvents (Page p)\r
- {\r
- p.EnableEventValidation = false;\r
- Wizard w = new Wizard ();\r
- w.DisplayCancelButton = true;\r
- w.DisplaySideBar = true;\r
- \r
- w.CancelButtonClick += new EventHandler (w_CancelButtonClick);\r
- w.FinishButtonClick += new WizardNavigationEventHandler (w_FinishButtonClick);\r
- w.NextButtonClick += new WizardNavigationEventHandler (w_NextButtonClick);\r
- w.PreviousButtonClick += new WizardNavigationEventHandler (w_PreviousButtonClick);\r
- w.SideBarButtonClick += new WizardNavigationEventHandler (w_SideBarButtonClick);\r
- w.ID = "Wizard1";\r
-\r
- WizardStep ws = new WizardStep ();\r
- ws.ID = "step";\r
- ws.StepType = WizardStepType.Start;\r
- ws.Controls.Add (new LiteralControl ("StartType"));\r
-\r
- WizardStep ws2 = new WizardStep ();\r
- ws2.ID = "step2";\r
- ws2.StepType = WizardStepType.Finish;\r
- ws2.Controls.Add (new LiteralControl ("FinishType"));\r
-\r
- WizardStep ws3 = new WizardStep ();\r
- ws3.ID = "step3";\r
- ws3.StepType = WizardStepType.Complete;\r
- ws3.Controls.Add (new LiteralControl ("CompleteType"));\r
-\r
- w.DisplaySideBar = true;\r
- w.WizardSteps.Add (ws);\r
- w.WizardSteps.Add (ws2);\r
- w.WizardSteps.Add (ws3);\r
- p.Controls.Add (w);\r
- }\r
-\r
- static void w_SideBarButtonClick (object sender, WizardNavigationEventArgs e)\r
- {\r
- WebTest.CurrentTest.UserData = "SideBarButtonClick";\r
- }\r
-\r
- static void w_PreviousButtonClick (object sender, WizardNavigationEventArgs e)\r
- {\r
- WebTest.CurrentTest.UserData = "PreviousButtonClick";\r
- }\r
-\r
- static void w_NextButtonClick (object sender, WizardNavigationEventArgs e)\r
- {\r
- WebTest.CurrentTest.UserData = "NextButtonClick";\r
- }\r
-\r
- static void w_FinishButtonClick (object sender, WizardNavigationEventArgs e)\r
- {\r
- WebTest.CurrentTest.UserData = "FinishButtonClick";\r
- }\r
-\r
- static void w_CancelButtonClick (object sender, EventArgs e)\r
- {\r
- WebTest.CurrentTest.UserData = "CancelButtonClick";\r
- }\r
-\r
+ }
+
+ [Test]
+ [Category ("NunitWeb")]
+ public void Wizard_PostBackFireEvents_1 ()
+ {
+ WebTest t = new WebTest ();
+ PageDelegates pd = new PageDelegates ();
+ pd.PreInit = _postbackEvents;
+ t.Invoker = new PageInvoker (pd);
+ string html = t.Run ();
+ FormRequest fr = new FormRequest (t.Response, "form1");
+
+ //Cancel
+#if DOT_NET
+ fr.Controls.Add ("__EVENTTARGET");
+ fr.Controls.Add ("__EVENTARGUMENT");
+ fr.Controls.Add ("Wizard1$StartNavigationTemplateContainerID$CancelButton");
+ fr.Controls["__EVENTTARGET"].Value = "";
+ fr.Controls["__EVENTARGUMENT"].Value = "";
+ fr.Controls["Wizard1$StartNavigationTemplateContainerID$CancelButton"].Value = "Cancel";
+#else
+ fr.Controls.Add ("__EVENTTARGET");
+ fr.Controls.Add ("__EVENTARGUMENT");
+ fr.Controls.Add ("Wizard1:StartNavContainer:CancelButtonButton");
+ fr.Controls ["__EVENTTARGET"].Value = "";
+ fr.Controls ["__EVENTARGUMENT"].Value = "";
+ fr.Controls ["Wizard1:StartNavContainer:CancelButtonButton"].Value = "Cancel";
+#endif
+ t.Request = fr;
+ html = t.Run ();
+ Assert.AreEqual ("CancelButtonClick", t.UserData.ToString (), "Cancel");
+
+ // Next
+#if DOT_NET
+ fr.Controls.Add ("__EVENTTARGET");
+ fr.Controls.Add ("__EVENTARGUMENT");
+ fr.Controls.Add ("Wizard1$StartNavigationTemplateContainerID$StartNextButton");
+ fr.Controls["__EVENTTARGET"].Value = "";
+ fr.Controls["__EVENTARGUMENT"].Value = "";
+ fr.Controls["Wizard1$StartNavigationTemplateContainerID$StartNextButton"].Value = "Next";
+#else
+ fr.Controls.Add ("__EVENTTARGET");
+ fr.Controls.Add ("__EVENTARGUMENT");
+ fr.Controls.Add ("Wizard1:StartNavContainer:StartNextButtonButton");
+ fr.Controls["__EVENTTARGET"].Value = "";
+ fr.Controls["__EVENTARGUMENT"].Value = "";
+ fr.Controls ["Wizard1:StartNavContainer:StartNextButtonButton"].Value = "Next";
+#endif
+ t.Request = fr;
+ html = t.Run ();
+ Assert.AreEqual ("NextButtonClick", t.UserData.ToString (), "Next");
+
+ // Previous
+ fr = new FormRequest (t.Response, "form1");
+#if DOT_NET
+ fr.Controls.Add ("__EVENTTARGET");
+ fr.Controls.Add ("__EVENTARGUMENT");
+ fr.Controls.Add ("Wizard1$FinishNavigationTemplateContainerID$FinishPreviousButton");
+
+ fr.Controls["__EVENTTARGET"].Value = "";
+ fr.Controls["__EVENTARGUMENT"].Value = "";
+ fr.Controls["Wizard1$FinishNavigationTemplateContainerID$FinishPreviousButton"].Value = "Previous";
+#else
+ fr.Controls.Add ("__EVENTTARGET");
+ fr.Controls.Add ("__EVENTARGUMENT");
+ fr.Controls.Add ("Wizard1:FinishNavContainer:FinishPreviousButtonButton");
+
+ fr.Controls ["__EVENTTARGET"].Value = "";
+ fr.Controls ["__EVENTARGUMENT"].Value = "";
+ fr.Controls ["Wizard1:FinishNavContainer:FinishPreviousButtonButton"].Value = "Previous";
+#endif
+ t.Request = fr;
+ html = t.Run ();
+ Assert.AreEqual ("PreviousButtonClick", t.UserData.ToString (), "Previous");
+
+ }
+
+ [Test]
+ [Category ("NunitWeb")]
+ public void Wizard_PostBackFireEvents_2 ()
+ {
+ WebTest t = new WebTest ();
+ PageDelegates pd = new PageDelegates ();
+ pd.PreInit = _postbackEvents;
+ t.Invoker = new PageInvoker (pd);
+ string html = t.Run ();
+ FormRequest fr = new FormRequest (t.Response, "form1");
+
+ // Next
+#if DOT_NET
+ fr.Controls.Add ("__EVENTTARGET");
+ fr.Controls.Add ("__EVENTARGUMENT");
+ fr.Controls.Add ("Wizard1$StartNavigationTemplateContainerID$StartNextButton");
+ fr.Controls["__EVENTTARGET"].Value = "";
+ fr.Controls["__EVENTARGUMENT"].Value = "";
+ fr.Controls["Wizard1$StartNavigationTemplateContainerID$StartNextButton"].Value = "Next";
+#else
+ fr.Controls.Add ("__EVENTTARGET");
+ fr.Controls.Add ("__EVENTARGUMENT");
+ fr.Controls.Add ("Wizard1:StartNavContainer:StartNextButtonButton");
+ fr.Controls ["__EVENTTARGET"].Value = "";
+ fr.Controls ["__EVENTARGUMENT"].Value = "";
+ fr.Controls ["Wizard1:StartNavContainer:StartNextButtonButton"].Value = "Next";
+#endif
+ t.Request = fr;
+ html = t.Run ();
+ Assert.AreEqual ("NextButtonClick", t.UserData.ToString (), "Next");
+
+ // Finish
+ fr = new FormRequest (t.Response, "form1");
+#if DOT_NET
+ fr.Controls.Add ("__EVENTTARGET");
+ fr.Controls.Add ("__EVENTARGUMENT");
+ fr.Controls.Add ("Wizard1$FinishNavigationTemplateContainerID$FinishButton");
+ fr.Controls["__EVENTTARGET"].Value = "";
+ fr.Controls["__EVENTARGUMENT"].Value = "";
+ fr.Controls["Wizard1$FinishNavigationTemplateContainerID$FinishButton"].Value = "Finish";
+#else
+ fr.Controls.Add ("__EVENTTARGET");
+ fr.Controls.Add ("__EVENTARGUMENT");
+ fr.Controls.Add ("Wizard1:FinishNavContainer:FinishButtonButton");
+ fr.Controls ["__EVENTTARGET"].Value = "";
+ fr.Controls ["__EVENTARGUMENT"].Value = "";
+ fr.Controls ["Wizard1:FinishNavContainer:FinishButtonButton"].Value = "Finish";
+#endif
+ t.Request = fr;
+ t.Run ();
+ Assert.AreEqual ("FinishButtonClick", t.UserData.ToString (), "Finish");
+
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ [Category ("NunitWeb")]
+ public void Wizard_PostBackFireEvents_3 ()
+ {
+ WebTest t = new WebTest ();
+ PageDelegates pd = new PageDelegates ();
+ pd.PreInit = _postbackEvents;
+ t.Invoker = new PageInvoker (pd);
+ string html = t.Run ();
+ FormRequest fr = new FormRequest (t.Response, "form1");
+
+ //SideBarButton
+ fr = new FormRequest (t.Response, "form1");
+#if DOT_NET
+ fr.Controls.Add ("__EVENTTARGET");
+ fr.Controls.Add ("__EVENTARGUMENT");
+
+ fr.Controls["__EVENTTARGET"].Value = "Wizard1$SideBarContainer$SideBarList$ctl01$SideBarButton";
+ fr.Controls["__EVENTARGUMENT"].Value = "";
+#else
+ fr.Controls.Add ("__EVENTTARGET");
+ fr.Controls.Add ("__EVENTARGUMENT");
+
+ fr.Controls ["__EVENTTARGET"].Value = "Wizard1:_ctl1c:SideBarList:_ctl0:SideBarButton";
+ fr.Controls ["__EVENTARGUMENT"].Value = "";
+#endif
+ t.Request = fr;
+ html = t.Run ();
+ Assert.AreEqual ("SideBarButtonClick", t.UserData.ToString (), "SideBarButton");
+ }
+
+ public static void _postbackEvents (Page p)
+ {
+ p.EnableEventValidation = false;
+ Wizard w = new Wizard ();
+ w.DisplayCancelButton = true;
+ w.DisplaySideBar = true;
+
+ w.CancelButtonClick += new EventHandler (w_CancelButtonClick);
+ w.FinishButtonClick += new WizardNavigationEventHandler (w_FinishButtonClick);
+ w.NextButtonClick += new WizardNavigationEventHandler (w_NextButtonClick);
+ w.PreviousButtonClick += new WizardNavigationEventHandler (w_PreviousButtonClick);
+ w.SideBarButtonClick += new WizardNavigationEventHandler (w_SideBarButtonClick);
+ w.ID = "Wizard1";
+
+ WizardStep ws = new WizardStep ();
+ ws.ID = "step";
+ ws.StepType = WizardStepType.Start;
+ ws.Controls.Add (new LiteralControl ("StartType"));
+
+ WizardStep ws2 = new WizardStep ();
+ ws2.ID = "step2";
+ ws2.StepType = WizardStepType.Finish;
+ ws2.Controls.Add (new LiteralControl ("FinishType"));
+
+ WizardStep ws3 = new WizardStep ();
+ ws3.ID = "step3";
+ ws3.StepType = WizardStepType.Complete;
+ ws3.Controls.Add (new LiteralControl ("CompleteType"));
+
+ w.DisplaySideBar = true;
+ w.WizardSteps.Add (ws);
+ w.WizardSteps.Add (ws2);
+ w.WizardSteps.Add (ws3);
+ p.Controls.Add (w);
+ }
+
+ static void w_SideBarButtonClick (object sender, WizardNavigationEventArgs e)
+ {
+ WebTest.CurrentTest.UserData = "SideBarButtonClick";
+ }
+
+ static void w_PreviousButtonClick (object sender, WizardNavigationEventArgs e)
+ {
+ WebTest.CurrentTest.UserData = "PreviousButtonClick";
+ }
+
+ static void w_NextButtonClick (object sender, WizardNavigationEventArgs e)
+ {
+ WebTest.CurrentTest.UserData = "NextButtonClick";
+ }
+
+ static void w_FinishButtonClick (object sender, WizardNavigationEventArgs e)
+ {
+ WebTest.CurrentTest.UserData = "FinishButtonClick";
+ }
+
+ static void w_CancelButtonClick (object sender, EventArgs e)
+ {
+ WebTest.CurrentTest.UserData = "CancelButtonClick";
+ }
+
[Test]
[Category ("NunitWeb")]
public void Wizard_PostBack()
{
p.EnableEventValidation = false;
Wizard w = new Wizard ();
- w.ID = "Wizard";\r
+ w.ID = "Wizard";
WizardStep ws = new WizardStep ();
ws.ID = "step";
w.WizardSteps.Add (ws4);
p.Controls.Add (w);
- }\r
-\r
+ }
+
public static void _readControl (Page p)
{
ArrayList list = new ArrayList();