2010-07-21 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Wed, 21 Jul 2010 12:58:22 +0000 (12:58 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Wed, 21 Jul 2010 12:58:22 +0000 (12:58 -0000)
* Wizard.cs: made rendering 100% compliant with .NET (button IDs,
2.0+)
Implemented LayoutTemplate (4.0+)

* LinkButton.cs: render id first

* CreateUserWizard.cs: CreateUserNavigationContainer.UpdateState
doesn't add a previous button if we're on the first step.

svn path=/trunk/mcs/; revision=160657

mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/System.Web.UI.WebControls/CreateUserWizard.cs
mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs
mcs/class/System.Web/System.Web.UI.WebControls/TableStyle.cs
mcs/class/System.Web/System.Web.UI.WebControls/Wizard.cs
mcs/class/System.Web/System.Web.UI.WebControls/WizardLayoutContainer.cs [new file with mode: 0644]
mcs/class/System.Web/System.Web.UI.WebControls/WizardLayoutNavigationContainer.cs [new file with mode: 0644]
mcs/class/System.Web/System.Web.UI/Control.cs
mcs/class/System.Web/Test/System.Web.UI.WebControls/WizardTest.cs
mcs/class/System.Web/net_4_0_System.Web.dll.sources

index b37f3381215190c98096dedb3656564cf968d9ff..75312bac638b3a629446d71550cf2706cb05beba 100644 (file)
@@ -1,3 +1,14 @@
+2010-07-21  Marek Habersack  <mhabersack@novell.com>
+
+       * Wizard.cs: made rendering 100% compliant with .NET (button IDs,
+       2.0+)
+       Implemented LayoutTemplate (4.0+)
+
+       * LinkButton.cs: render id first
+
+       * CreateUserWizard.cs: CreateUserNavigationContainer.UpdateState
+       doesn't add a previous button if we're on the first step.
+
 2010-07-20  Marek Habersack  <mhabersack@novell.com>
 
        * StyleCollection.cs: added
index c6f9dfd9bd692fca9149ec50ab01801dbd9f278b..f29bb0bd1e733fa80539c3ed8c839971ae74f423 100644 (file)
@@ -1122,7 +1122,7 @@ namespace System.Web.UI.WebControls
 
                        if (CompleteStep == null)
                                WizardSteps.AddAt (WizardSteps.Count, new CompleteWizardStep ());
-
+                       
                        base.CreateChildControls ();
                }
 
@@ -1589,23 +1589,20 @@ namespace System.Web.UI.WebControls
                        protected override void UpdateState ()
                        {
                                // previous
-                               if (_createUserWizard.AllowNavigationToStep (_createUserWizard.ActiveStepIndex - 1)) {
+                               int previous = _createUserWizard.ActiveStepIndex - 1;
+                               if (previous >= 0 && _createUserWizard.AllowNavigationToStep (previous))
                                        UpdateNavButtonState (Wizard.StepPreviousButtonID + Wizard.StepPreviousButtonType, Wizard.StepPreviousButtonText, Wizard.StepPreviousButtonImageUrl, Wizard.StepPreviousButtonStyle);
-                               }
-                               else {
+                               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) {
+                               if (Wizard.DisplayCancelButton)
                                        UpdateNavButtonState (Wizard.CancelButtonID + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
-                               }
-                               else {
+                               else
                                        ((Table) Controls [0]).Rows [0].Cells [2].Visible = false;
-                               }
                        }
                }
 
index 52082fb205c331dc3e36e2d5fa32f1f4e3d69bfc..a6f8ad4b39d51c2cc6cc3fb8144ecb04d5d7b5f8 100644 (file)
@@ -55,6 +55,7 @@ namespace System.Web.UI.WebControls
                        if (page != null)
                                page.VerifyRenderingInServerForm (this);
 
+                       base.AddAttributesToRender (w);
                        bool enabled = IsEnabled;
                        string onclick = OnClientClick;
                        onclick = ClientScriptManager.EnsureEndsWithSemicolon (onclick);
@@ -71,7 +72,7 @@ namespace System.Web.UI.WebControls
                                string href = page.ClientScript.GetPostBackEventReference (options, true);
                                w.AddAttribute (HtmlTextWriterAttribute.Href, href);
                        }
-                       base.AddAttributesToRender (w);
+                       
                        AddDisplayStyleAttribute (w);
                }
 
index 2bf6d576989b8bc36b9fda312032bb4675de7ee8..142d1b74708f688e1aef8a853884940a5c7acfce 100644 (file)
@@ -185,17 +185,17 @@ namespace System.Web.UI.WebControls {
                                return;
 
                        // note: avoid calling properties multiple times
-                       int i = CellPadding;
-                       if (i != -1)
-                               writer.AddAttribute (HtmlTextWriterAttribute.Cellpadding, i.ToString (Helpers.InvariantCulture), false);
-                       
-                       i = CellSpacing;
+                       int i = CellSpacing;
                        if (i != -1) {
                                writer.AddAttribute (HtmlTextWriterAttribute.Cellspacing, i.ToString (Helpers.InvariantCulture), false);
                                if (i == 0)
                                        writer.AddStyleAttribute(HtmlTextWriterStyle.BorderCollapse, "collapse");
                        }
 
+                       i = CellPadding;
+                       if (i != -1)
+                               writer.AddAttribute (HtmlTextWriterAttribute.Cellpadding, i.ToString (Helpers.InvariantCulture), false);
+                       
                        GridLines g = GridLines;
                        switch (g) {
                        case GridLines.Horizontal:
index b546e163e9b3c7083ca9dfeecd96df84f61910d1..6ab0e00c45ebadd32a259b7531600ea59ca81ae5 100644 (file)
@@ -32,6 +32,7 @@
 
 using System;
 using System.Collections;
+using System.Collections.Generic;
 using System.ComponentModel;
 using System.Web.UI;
 
@@ -48,18 +49,43 @@ namespace System.Web.UI.WebControls
                public static readonly string MoveNextCommandName = "MoveNext";
                public static readonly string MovePreviousCommandName = "MovePrevious";
                public static readonly string MoveToCommandName = "Move";
-               
-               protected static readonly string CancelButtonID = "CancelButton";
-               protected static readonly string CustomFinishButtonID = "CustomFinishButton";
-               protected static readonly string CustomNextButtonID = "CustomNextButton";
-               protected static readonly string CustomPreviousButtonID = "CustomPreviousButton";
+#if NET_4_0
+               public static readonly string HeaderPlaceholderId = "headerPlaceholder";
+               public static readonly string NavigationPlaceholderId = "navigationPlaceholder";
+               public static readonly string SideBarPlaceholderId = "sideBarPlaceholder";
+               public static readonly string WizardStepPlaceholderId = "wizardStepPlaceholder";
+#endif
                protected static readonly string DataListID = "SideBarList";
-               protected static readonly string FinishButtonID = "FinishButton";
-               protected static readonly string FinishPreviousButtonID = "FinishPreviousButton";
-               protected static readonly string SideBarButtonID = "SideBarButton";
-               protected static readonly string StartNextButtonID = "StartNextButton";
-               protected static readonly string StepNextButtonID = "StepNextButton";
-               protected static readonly string StepPreviousButtonID = "StepPreviousButton";
+
+               static readonly string CancelButtonIDShort = "Cancel";
+               protected static readonly string CancelButtonID = CancelButtonIDShort + "Button";
+               
+               static readonly string CustomFinishButtonIDShort = "CustomFinish";
+               protected static readonly string CustomFinishButtonID = CustomFinishButtonIDShort + "Button";
+               
+               static readonly string CustomNextButtonIDShort = "CustomNext";
+               protected static readonly string CustomNextButtonID = CustomNextButtonIDShort + "Button";
+
+               static readonly string CustomPreviousButtonIDShort = "CustomPrevious";
+               protected static readonly string CustomPreviousButtonID = CustomPreviousButtonIDShort + "Button";
+
+               static readonly string FinishButtonIDShort = "Finish";
+               protected static readonly string FinishButtonID = FinishButtonIDShort + "Button";
+
+               static readonly string FinishPreviousButtonIDShort = "FinishPrevious";
+               protected static readonly string FinishPreviousButtonID = FinishPreviousButtonIDShort + "Button";
+
+               static readonly string SideBarButtonIDShort = "SideBar";
+               protected static readonly string SideBarButtonID = SideBarButtonIDShort + "Button";
+
+               static readonly string StartNextButtonIDShort = "StartNext";
+               protected static readonly string StartNextButtonID = StartNextButtonIDShort + "Button";
+
+               static readonly string StepNextButtonIDShort = "StepNext";
+               protected static readonly string StepNextButtonID = StepNextButtonIDShort + "Button";
+
+               static readonly string StepPreviousButtonIDShort = "StepPrevious";
+               protected static readonly string StepPreviousButtonID = StepPreviousButtonIDShort + "Button";
                
                WizardStepCollection steps;
                
@@ -84,7 +110,7 @@ namespace System.Web.UI.WebControls
                ITemplate stepNavigationTemplate;
                ITemplate headerTemplate;
                ITemplate sideBarTemplate;
-               
+
                // Control state
                
                int activeStepIndex = -1;
@@ -186,15 +212,17 @@ namespace System.Web.UI.WebControls
                                if (eh != null) eh (this, e);
                        }
                }
-               
+
            [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
            [BrowsableAttribute (false)]
                public WizardStepBase ActiveStep {
                        get {
-                               if (ActiveStepIndex < -1 || ActiveStepIndex >= WizardSteps.Count)
+                               int activeIndex = ActiveStepIndex;
+                               if (activeIndex < -1 || activeIndex >= WizardSteps.Count)
                                        throw new InvalidOperationException ("ActiveStepIndex has an invalid value.");
-                               if (ActiveStepIndex == -1) return null;
-                               return WizardSteps [activeStepIndex];
+                               if (activeIndex == -1)
+                                       return null;
+                               return WizardSteps [activeIndex];
                        }
                }
                
@@ -209,7 +237,7 @@ namespace System.Web.UI.WebControls
                                    throw new ArgumentOutOfRangeException ("The ActiveStepIndex must be less than WizardSteps.Count and at least -1");
                            if (inited && !AllowNavigationToStep (value))
                                    return;
-
+                           
                            if(activeStepIndex != value) {
                                    activeStepIndex = value;
                                    
@@ -496,7 +524,13 @@ namespace System.Web.UI.WebControls
                                ViewState ["HeaderText"] = value;
                        }
                }
-               
+#if NET_4_0
+           [DefaultValue (null)]
+           [TemplateContainerAttribute(typeof(Wizard))]
+                   [PersistenceModeAttribute(PersistenceMode.InnerProperty)]
+                   [BrowsableAttribute(false)]
+                   public virtual ITemplate LayoutTemplate { get; set; }
+#endif
            [DefaultValueAttribute (null)]
            [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
            [NotifyParentPropertyAttribute (true)]
@@ -789,16 +823,19 @@ namespace System.Web.UI.WebControls
                
                public ICollection GetHistory ()
                {
-                       if (history == null) history = new ArrayList ();
+                       if (history == null)
+                               history = new ArrayList ();
                        return history;
                }
                
                public void MoveTo (WizardStepBase wizardStep)
                {
-                       if (wizardStep == null) throw new ArgumentNullException ("wizardStep");
+                       if (wizardStep == null)
+                               throw new ArgumentNullException ("wizardStep");
                        
                        int i = WizardSteps.IndexOf (wizardStep);
-                       if (i == -1) throw new ArgumentException ("The provided wizard step does not belong to this wizard.");
+                       if (i == -1)
+                               throw new ArgumentException ("The provided wizard step does not belong to this wizard.");
                        
                        ActiveStepIndex = i;
                }
@@ -822,9 +859,9 @@ namespace System.Web.UI.WebControls
                
                protected virtual bool AllowNavigationToStep (int index)
                {
-                       if (index < 0 || index >= WizardSteps.Count) return false;
-                       if (history == null) return true;
-                       if (!history.Contains (index)) return true;
+                       if ((index < 0 || index >= WizardSteps.Count) || history == null || !history.Contains (index))
+                               return true;
+                       
                        return WizardSteps [index].AllowReturn;
                } 
                
@@ -852,9 +889,104 @@ namespace System.Web.UI.WebControls
                {
                        CreateControlHierarchy ();
                }
+#if NET_4_0
+               InvalidOperationException MakeLayoutException (string phName, string phID, string condition = null)
+               {
+                       return new InvalidOperationException (
+                               String.Format ("A {0} placeholder must be specified on Wizard '{1}'{2}. Specify a placeholder by setting a control's ID property to \"{3}\". The placeholder control must also specify runat=\"server\"",
+                                              phName, ID, condition, phID)
+                       );
+               }
+
+               void CreateControlHierarchy_LayoutTemplate (ITemplate layoutTemplate)
+               {
+                       var layoutContainer = new WizardLayoutContainer ();
+                       ControlCollection controls = Controls;
+
+                       controls.SetReadonly (false);                   
+                       controls.Add (layoutContainer);
+                       controls.SetReadonly (true);
+                       
+                       layoutTemplate.InstantiateIn (layoutContainer);
+
+                       WizardStepCollection steps = WizardSteps;
+                       bool doRender = steps != null && steps.Count > 0;
+                       Control container, placeHolder;
+                       
+                       if (DisplaySideBar) {
+                               placeHolder = layoutContainer.FindControl (SideBarPlaceholderId);
+                               if (placeHolder == null)
+                                       throw MakeLayoutException ("sidebar", SideBarPlaceholderId, " when DisplaySideBar is set to true");
+
+                               container = new Control ();
+                               CreateSideBar (container);
+                               ReplacePlaceHolder (layoutContainer, placeHolder, container);
+                       }
+
+                       ITemplate headerTemplate = HeaderTemplate;
+                       if (headerTemplate != null) {
+                               placeHolder = layoutContainer.FindControl (HeaderPlaceholderId);
+                               if (placeHolder == null)
+                                       throw MakeLayoutException ("header", HeaderPlaceholderId, " when HeaderTemplate is set");
+                               
+                               container = new Control ();
+                               headerTemplate.InstantiateIn (container);
+                               ReplacePlaceHolder (layoutContainer, placeHolder, container);
+                       }
+
+                       placeHolder = layoutContainer.FindControl (WizardStepPlaceholderId);
+                       if (placeHolder == null)
+                               throw MakeLayoutException ("step", WizardStepPlaceholderId);
+                       
+                       customNavigation = null;
+                       multiView = new MultiView ();
+                       foreach (View v in steps) {
+                               if (v is TemplatedWizardStep)
+                                       InstantiateTemplateStep ((TemplatedWizardStep) v);
+                               multiView.Views.Add (v);
+                       }
+                       multiView.ActiveViewIndex = ActiveStepIndex;
+                       ReplacePlaceHolder (layoutContainer, placeHolder, multiView);
+
+                       placeHolder = layoutContainer.FindControl (NavigationPlaceholderId);
+                       if (placeHolder == null)
+                               throw MakeLayoutException ("navigation", NavigationPlaceholderId);
+
+                       
+                       var contentTable = new Table ();
+                       contentTable.CellSpacing = 5;
+                       contentTable.CellPadding = 5;
+                       var row = new TableRow ();
+                       var cell = new TableCell ();
+                       cell.HorizontalAlign = HorizontalAlign.Right;
+
+                       container = new Control ();
+                       CreateButtonBar (container);
+                       
+                       row.Cells.Add (cell);
+                       contentTable.Rows.Add (row);
+                       ReplacePlaceHolder (layoutContainer, placeHolder, container);
+
+                       layoutContainer.Visible = doRender;
+               }
 
+               void ReplacePlaceHolder (WebControl container, Control placeHolder, Control replacement)
+               {
+                       ControlCollection controls = container.Controls;
+                       int index = controls.IndexOf (placeHolder);
+                       controls.Remove (placeHolder);
+                       controls.AddAt (index, replacement);
+               }
+#endif
                protected virtual void CreateControlHierarchy ()
                {
+#if NET_4_0
+                       ITemplate layoutTemplate = LayoutTemplate;
+                       if (layoutTemplate != null) {
+                               CreateControlHierarchy_LayoutTemplate (layoutTemplate);
+                               return;
+                       }
+#endif
                        styles.Clear ();
 
                        wizardTable = new ContainedTable (this);
@@ -937,20 +1069,20 @@ namespace System.Web.UI.WebControls
                        step.CustomNavigationTemplateContainer = customNavigationTemplateContainer;
                }
 
-               internal void RegisterCustomNavigation (TemplatedWizardStep step, BaseWizardNavigationContainer customNavigationTemplateContainer) {
+               internal void RegisterCustomNavigation (TemplatedWizardStep step, BaseWizardNavigationContainer customNavigationTemplateContainer)
+               {
                        if (customNavigation == null)
                                customNavigation = new Hashtable ();
                        customNavigation [step] = customNavigationTemplateContainer;
                }
                
-               void CreateButtonBar (TableCell buttonBarCell)
+               void CreateButtonBar (Control container)
                {
-                       if(customNavigation!=null && customNavigation.Values.Count>0)
-                       {
+                       if(customNavigation != null && customNavigation.Values.Count > 0 ) {
                                int i = 0;
                                foreach (Control customNavigationTemplateContainer in customNavigation.Values) {
-                                       customNavigationTemplateContainer.ID = "CustomNavContainer" + i++;
-                                       buttonBarCell.Controls.Add (customNavigationTemplateContainer);
+                                       customNavigationTemplateContainer.ID = "CustomNavigationTemplateContainerID" + i++;
+                                       container.Controls.Add (customNavigationTemplateContainer);
                                }
                        }
                        
@@ -958,54 +1090,51 @@ namespace System.Web.UI.WebControls
                        // StartNavContainer
                        //
                        _startNavContainer = new StartNavigationContainer (this);
-                       _startNavContainer.ID = "StartNavContainer";
-                       if (startNavigationTemplate != null) {
+                       _startNavContainer.ID = "StartNavigationTemplateContainerID";
+                       if (startNavigationTemplate != null)
                                startNavigationTemplate.InstantiateIn (_startNavContainer);
-                       }
                        else {
                                TableRow row;
                                AddNavButtonsTable (_startNavContainer, out row);
-                               AddButtonCell (row, CreateButtonSet (StartNextButtonID, MoveNextCommandName));
-                               AddButtonCell (row, CreateButtonSet (CancelButtonID, CancelCommandName, false));
+                               AddButtonCell (row, CreateButtonSet (StartNextButtonIDShort, MoveNextCommandName));
+                               AddButtonCell (row, CreateButtonSet (CancelButtonIDShort, CancelCommandName, false));
                                _startNavContainer.ConfirmDefaultTemplate ();
                        }
-                       buttonBarCell.Controls.Add (_startNavContainer);
+                       container.Controls.Add (_startNavContainer);
 
                        //
                        // StepNavContainer
                        //
                        _stepNavContainer = new StepNavigationContainer (this);
-                       _stepNavContainer.ID = "StepNavContainer";
-                       if (stepNavigationTemplate != null) {
+                       _stepNavContainer.ID = "StepNavigationTemplateContainerID";
+                       if (stepNavigationTemplate != null)
                                stepNavigationTemplate.InstantiateIn (_stepNavContainer);
-                       }
                        else {
                                TableRow row;
                                AddNavButtonsTable (_stepNavContainer, out row);
-                               AddButtonCell (row, CreateButtonSet (StepPreviousButtonID, MovePreviousCommandName, false));
-                               AddButtonCell (row, CreateButtonSet (StepNextButtonID, MoveNextCommandName));
-                               AddButtonCell (row, CreateButtonSet (CancelButtonID, CancelCommandName, false));
+                               AddButtonCell (row, CreateButtonSet (StepPreviousButtonIDShort, MovePreviousCommandName, false));
+                               AddButtonCell (row, CreateButtonSet (StepNextButtonIDShort, MoveNextCommandName));
+                               AddButtonCell (row, CreateButtonSet (CancelButtonIDShort, CancelCommandName, false));
                                _stepNavContainer.ConfirmDefaultTemplate ();
                        }
-                       buttonBarCell.Controls.Add (_stepNavContainer);
+                       container.Controls.Add (_stepNavContainer);
 
                        //
                        // StepNavContainer
                        //
                        _finishNavContainer = new FinishNavigationContainer (this);
-                       _finishNavContainer.ID = "FinishNavContainer";
-                       if (finishNavigationTemplate != null) {
+                       _finishNavContainer.ID = "FinishNavigationTemplateContainerID";
+                       if (finishNavigationTemplate != null)
                                finishNavigationTemplate.InstantiateIn (_finishNavContainer);
-                       }
                        else {
                                TableRow row;
                                AddNavButtonsTable (_finishNavContainer, out row);
-                               AddButtonCell (row, CreateButtonSet (FinishPreviousButtonID, MovePreviousCommandName, false));
-                               AddButtonCell (row, CreateButtonSet (FinishButtonID, MoveCompleteCommandName));
-                               AddButtonCell (row, CreateButtonSet (CancelButtonID, CancelCommandName, false));
+                               AddButtonCell (row, CreateButtonSet (FinishPreviousButtonIDShort, MovePreviousCommandName, false));
+                               AddButtonCell (row, CreateButtonSet (FinishButtonIDShort, MoveCompleteCommandName));
+                               AddButtonCell (row, CreateButtonSet (CancelButtonIDShort, CancelCommandName, false));
                                _finishNavContainer.ConfirmDefaultTemplate ();
                        }
-                       buttonBarCell.Controls.Add (_finishNavContainer);
+                       container.Controls.Add (_finishNavContainer);
                }
 
                static void AddNavButtonsTable (BaseWizardNavigationContainer container, out TableRow row)
@@ -1036,13 +1165,13 @@ namespace System.Web.UI.WebControls
                                CreateButton ( id + ButtonType.Link,  command, ButtonType.Link, causesValidation, validationGroup)
                                };
                }
-
+               
                Control CreateButton (string id, string command, ButtonType type, bool causesValidation, string validationGroup)
                {
                        WebControl b;
                        switch (type) {
                        case ButtonType.Button:
-                               b = CreateStandartButton ();
+                               b = CreateStandardButton ();
                                break;
                        case ButtonType.Image:
                                b = CreateImageButton (null);
@@ -1066,7 +1195,7 @@ namespace System.Web.UI.WebControls
                        return b;
                }
 
-               WebControl CreateStandartButton () {
+               WebControl CreateStandardButton () {
                        Button btn = new Button ();
                        return btn;
                }
@@ -1091,12 +1220,15 @@ namespace System.Web.UI.WebControls
                        row.Cells.Add (cell);
                }
                
-               void CreateSideBar (TableCell sideBarCell)
+               void CreateSideBar (Control container)
                {
-                       RegisterApplyStyle (sideBarCell, SideBarStyle);
+                       WebControl wctl = container as WebControl;
+                       if (wctl != null)
+                               RegisterApplyStyle (wctl, SideBarStyle);
+
                        if (sideBarTemplate != null) {
-                               sideBarTemplate.InstantiateIn (sideBarCell);
-                               stepDatalist = sideBarCell.FindControl (DataListID) as DataList;
+                               sideBarTemplate.InstantiateIn (container);
+                               stepDatalist = container.FindControl (DataListID) as DataList;
                                if (stepDatalist == null)
                                        throw new InvalidOperationException ("The side bar template must contain a DataList control with id '" + DataListID + "'.");
                                stepDatalist.ItemDataBound += new DataListItemEventHandler(StepDatalistItemDataBound);
@@ -1105,7 +1237,7 @@ namespace System.Web.UI.WebControls
                                stepDatalist.ID = DataListID;
                                stepDatalist.SelectedItemStyle.Font.Bold = true;
                                stepDatalist.ItemTemplate = SideBarItemTemplate;
-                               sideBarCell.Controls.Add (stepDatalist);
+                               container.Controls.Add (stepDatalist);
                        }
 
                        stepDatalist.ItemCommand += new DataListCommandEventHandler (StepDatalistItemCommand);
@@ -1143,7 +1275,7 @@ namespace System.Web.UI.WebControls
                                        ((WebControl) button).Enabled = false;
                        }
                }
-
+               
                void AddHeaderRow (Table table)
                {
                        TableRow row = new TableRow ();
@@ -1379,23 +1511,40 @@ namespace System.Web.UI.WebControls
                protected internal override void Render (HtmlTextWriter writer)
                {
                        PrepareControlHierarchy ();
-                       
-                       wizardTable.Render (writer);
+#if NET_4_0
+                       if (LayoutTemplate == null)
+#endif
+                               wizardTable.Render (writer);
+#if NET_4_0
+                       else
+                               RenderChildren (writer);
+#endif
                }
 
                void PrepareControlHierarchy ()
                {
-                       // header
-                       if (!_headerCell.Initialized) {
-                               if (String.IsNullOrEmpty (HeaderText))
-                                       _headerCell.Parent.Visible = false;
-                               else
-                                       _headerCell.Text = HeaderText;
-                       }
+#if NET_4_0
+                       if (LayoutTemplate == null) {
+#endif
+                               // header
+                               if (!_headerCell.Initialized) {
+                                       if (String.IsNullOrEmpty (HeaderText))
+                                               _headerCell.Parent.Visible = false;
+                                       else
+                                               _headerCell.Text = HeaderText;
+                               }
 
-                       if (ActiveStep.StepType == WizardStepType.Complete)
-                               _headerCell.Parent.Visible = false;
+                               if (ActiveStep.StepType == WizardStepType.Complete)
+                                       _headerCell.Parent.Visible = false;
+#if NET_4_0
+                       } else {
+                               WizardStepCollection steps = WizardSteps;
 
+                               if (steps == null || steps.Count == 0)
+                                       return;
+                       }
+#endif
+                       
                        // sidebar
                        if (stepDatalist != null) {
                                stepDatalist.SelectedIndex = ActiveStepIndex;
@@ -1424,12 +1573,12 @@ namespace System.Web.UI.WebControls
 
                        BaseWizardNavigationContainer currentNavContainer = GetCurrentNavContainer ();
                        if (currentNavContainer == null) {
-                               _navigationCell.Parent.Visible = false;
-                       }
-                       else {
+                               if (_navigationCell != null)
+                                       _navigationCell.Parent.Visible = false;
+                       else {
                                currentNavContainer.Visible = true;
                                currentNavContainer.PrepareControlHierarchy ();
-                               if (!currentNavContainer.Visible)
+                               if (_navigationCell != null && !currentNavContainer.Visible)
                                        _navigationCell.Parent.Visible = false;
                        }
 
@@ -1614,20 +1763,17 @@ namespace System.Web.UI.WebControls
                                // next
                                if (Wizard.AllowNavigationToStep (Wizard.ActiveStepIndex + 1)) {
                                        visible = true;
-                                       UpdateNavButtonState (Wizard.StartNextButtonID + Wizard.StartNextButtonType, Wizard.StartNextButtonText, Wizard.StartNextButtonImageUrl, Wizard.StartNextButtonStyle);
-                               }
-                               else {
+                                       UpdateNavButtonState (Wizard.StartNextButtonIDShort + 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 {
+                                       UpdateNavButtonState (Wizard.CancelButtonIDShort + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
+                               } else
                                        ((Table) Controls [0]).Rows [0].Cells [1].Visible = false;
-                               }
+
                                Visible = visible;
                        }
                }
@@ -1642,33 +1788,27 @@ namespace System.Web.UI.WebControls
                        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 {
+                                       UpdateNavButtonState (Wizard.StepPreviousButtonIDShort + 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 {
+                                       UpdateNavButtonState (Wizard.StepNextButtonIDShort + 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 {
+                                       UpdateNavButtonState (Wizard.CancelButtonIDShort + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
+                               } else
                                        ((Table) Controls [0]).Rows [0].Cells [2].Visible = false;
-                               }
+                               
                                Visible = visible;
                        }
                }
@@ -1683,23 +1823,20 @@ namespace System.Web.UI.WebControls
                        protected override void UpdateState ()
                        {
                                // previous
-                               if (Wizard.AllowNavigationToStep (Wizard.ActiveStepIndex - 1)) {
-                                       UpdateNavButtonState (Wizard.FinishPreviousButtonID + Wizard.FinishPreviousButtonType, Wizard.FinishPreviousButtonText, Wizard.FinishPreviousButtonImageUrl, Wizard.FinishPreviousButtonStyle);
-                               }
-                               else {
+                               int previous = Wizard.ActiveStepIndex - 1;
+                               if (previous >= 0 && Wizard.AllowNavigationToStep (previous)) {
+                                       UpdateNavButtonState (Wizard.FinishPreviousButtonIDShort + 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);
+                               UpdateNavButtonState (Wizard.FinishButtonIDShort + Wizard.FinishCompleteButtonType, Wizard.FinishCompleteButtonText, Wizard.FinishCompleteButtonImageUrl, Wizard.FinishCompleteButtonStyle);
 
                                // cancel
                                if (Wizard.DisplayCancelButton) {
-                                       UpdateNavButtonState (Wizard.CancelButtonID + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
-                               }
-                               else {
+                                       UpdateNavButtonState (Wizard.CancelButtonIDShort + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
+                               } else
                                        ((Table) Controls [0]).Rows [0].Cells [2].Visible = false;
-                               }
                        }
                }
 
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/WizardLayoutContainer.cs b/mcs/class/System.Web/System.Web.UI.WebControls/WizardLayoutContainer.cs
new file mode 100644 (file)
index 0000000..bf24588
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// Authors:
+//   Marek Habersack <mhabersack@novell.com>
+//
+// Copyright (C) 2010 Novell, Inc (http://novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+       sealed class WizardLayoutContainer : WebControl
+       {
+               protected internal override void Render (HtmlTextWriter writer)
+               {
+                       RenderChildren (writer);
+               }
+       }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/WizardLayoutNavigationContainer.cs b/mcs/class/System.Web/System.Web.UI.WebControls/WizardLayoutNavigationContainer.cs
new file mode 100644 (file)
index 0000000..bab2d56
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// Authors:
+//   Marek Habersack <mhabersack@novell.com>
+//
+// Copyright (C) 2010 Novell, Inc (http://novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+       sealed class WizardLayoutNavigationContainer : WebControl
+       {
+               protected internal override void Render (HtmlTextWriter writer)
+               {
+                       RenderChildren (writer);
+               }
+       }
+}
index 18057924129769bafe55b145bc92bb165c4fe732..4fe6e98d5dba497e60c9def5b198e3afe3c2c46c 100644 (file)
@@ -401,7 +401,14 @@ namespace System.Web.UI
                        }
 
                        if (!haveMyID) {
-                               sb.Append (myID);
+                               if (this is INamingContainer || !AutoID)
+                                       sb.Append (myID);
+                               else {
+                                       int length = sb.Length;
+                                       if (length > 0 && sb [length - 1] == separator)
+                                               sb.Length = length - 1;
+                               }
+                               
                                return sb.ToString ();
                        }
                        
index af912bb057f4b0ec54c78f9bcfe735248a245123..ffbe083b6a70c03759918f3e96176b96c05ad18c 100644 (file)
@@ -47,7 +47,7 @@ using MonoTests.SystemWeb.Framework;
 using MonoTests.stand_alone.WebHarness;
 using System.Threading;
 
-
+using MonoTests.Common;
 
 
 namespace MonoTests.System.Web.UI.WebControls
@@ -301,7 +301,67 @@ namespace MonoTests.System.Web.UI.WebControls
                        base.EnsureChildControls ();
                }
        }
+#if NET_4_0
+       class TestHeaderSpan : WebControl
+       {
+               public TestHeaderSpan ()
+                       : base (HtmlTextWriterTag.Span)
+               { }
+       }
+       class TestHeaderTemplate : ITemplate
+       {
+               public void InstantiateIn (Control container)
+               {
+                       container.Controls.Add (new LiteralControl ("Header"));
+               }
+       }
+
+       class TestLayoutTemplate : ITemplate
+       {
+               public bool HasHeaderPlaceHolder { get; set; }
+               public bool HasNavigationPlaceHolder { get; set; }
+               public bool HasSideBarPlaceHolder { get; set; }
+               public bool HasWizardStepPlaceHolder { get; set; }
+
+               public Type HeaderPlaceHolderType { get; set; }
+               public Type NavigationPlaceHolderType { get; set; }
+               public Type SideBarPlaceHolderType { get; set; }
+               public Type WizardStepPlaceHolderType { get; set; }
+
+               public TestLayoutTemplate ()
+               {
+                       HeaderPlaceHolderType = typeof (PlaceHolder);
+                       NavigationPlaceHolderType = typeof (PlaceHolder);
+                       SideBarPlaceHolderType = typeof (PlaceHolder);
+                       WizardStepPlaceHolderType = typeof (PlaceHolder);
+               }
+
+               public void InstantiateIn (Control container)
+               {
+                       if (HasHeaderPlaceHolder)
+                               container.Controls.Add (MakePlaceHolder (HeaderPlaceHolderType, Wizard.HeaderPlaceholderId));
+
+                       if (HasSideBarPlaceHolder)
+                               container.Controls.Add (MakePlaceHolder (SideBarPlaceHolderType, Wizard.SideBarPlaceholderId));
 
+                       if (HasNavigationPlaceHolder)
+                               container.Controls.Add (MakePlaceHolder (NavigationPlaceHolderType, Wizard.NavigationPlaceholderId));
+
+                       if (HasWizardStepPlaceHolder)
+                               container.Controls.Add (MakePlaceHolder (WizardStepPlaceHolderType, Wizard.WizardStepPlaceholderId));
+               }
+
+               Control MakePlaceHolder (Type type, string id)
+               {
+                       Control ctl = Activator.CreateInstance (type) as Control;
+                       if (ctl == null)
+                               throw new InvalidOperationException ("Placeholder must descend from the Control type.");
+
+                       ctl.ID = id;
+                       return ctl;
+               }
+       }
+#endif
        [TestFixture]
        public class WizardTest
        {
@@ -315,6 +375,12 @@ namespace MonoTests.System.Web.UI.WebControls
                        Assert.AreEqual ("MoveNext", Wizard.MoveNextCommandName, "MoveNextCommandName");
                        Assert.AreEqual ("MovePrevious", Wizard.MovePreviousCommandName, "MovePreviousCommandName");
                        Assert.AreEqual ("Move", Wizard.MoveToCommandName, "MoveToCommandName");
+#if NET_4_0
+                       Assert.AreEqual ("headerPlaceholder", Wizard.HeaderPlaceholderId, "HeaderPlaceHolderId");
+                       Assert.AreEqual ("navigationPlaceholder", Wizard.NavigationPlaceholderId, "NavigationPlaceHolderId");
+                       Assert.AreEqual ("sideBarPlaceholder", Wizard.SideBarPlaceholderId, "SidePlaceholderId");
+                       Assert.AreEqual ("wizardStepPlaceholder", Wizard.WizardStepPlaceholderId, "WizardStepPlaceholderId");
+#endif
                        // Protected Fields 
                        Assert.AreEqual ("CancelButton", PokerWizard.PokerCancelButtonID, "CancelButtonID");
                        Assert.AreEqual ("CustomFinishButton", PokerWizard.PokerCustomFinishButtonID, "CustomFinishButtonID");
@@ -1100,6 +1166,15 @@ namespace MonoTests.System.Web.UI.WebControls
                        Assert.AreEqual (false, result, "AllowNavigationToStep#2");
                }
 
+               [Test]
+               public void Wizard_AllowNavigationToStep_NoIndexCheck ()
+               {
+                       PokerWizard wizard = new PokerWizard ();
+                       Assert.IsTrue (wizard.PokerAllowNavigationToStep (0), "#A1-1");
+                       Assert.IsTrue (wizard.PokerAllowNavigationToStep (10), "#A1-2");
+                       Assert.IsTrue (wizard.PokerAllowNavigationToStep (-10), "#A1-3");
+               }
+
                [Test]
                public void Wizard_CreateControlCollection ()
                {
@@ -1456,7 +1531,229 @@ namespace MonoTests.System.Web.UI.WebControls
                                Assert.Fail ("FinishButtonNotCreated");
                        Assert.AreEqual (-1, result.IndexOf ("Next"), "NextButtonCreatedOnLastPage");
                }
+#if NET_4_0
+               [Test]
+               public void Wizard_LayoutTemplate ()
+               {
+                       var w = new Wizard ();
+
+                       Assert.IsNull (w.LayoutTemplate, "#A1");
+               }
+
+               [Test]
+               public void Wizard_LayoutTemplate_Empty ()
+               {
+                       WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
+                       t.UserData = "Empty";
+                       string result;
+
+                       AssertExtensions.Throws<InvalidOperationException> (() => {
+                               result = t.Run ();
+                       }, "#A1");
+               }
 
+               [Test]
+               public void Wizard_LayoutTemplate_OptionalSideBar ()
+               {
+                       WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
+                       t.UserData = "OptionalSideBar_NoSideBar";
+                       string result = t.Run ();
+                       string renderedHtml = HtmlDiff.GetControlFromPageHtml (result);
+
+                       Assert.AreEqual (String.Empty, renderedHtml, "#A1");
+
+                       t.UserData = "OptionalSideBar_WithSideBar";
+                       AssertExtensions.Throws<InvalidOperationException> (() => {
+                               result = t.Run ();
+                       }, "#A2");
+               }
+
+               [Test]
+               public void Wizard_LayoutTemplate_RenderSideBar ()
+               {
+                       WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
+                       t.UserData = "RenderSideBar";
+                       string result = t.Run ();
+#if DOT_NET
+                       string origHtml = "<table id=\"MyWizard_SideBarList\" cellspacing=\"0\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td style=\"font-weight:bold;\"><a id=\"MyWizard_SideBarList_SideBarButton_0\" href=\"javascript:__doPostBack(&#39;MyWizard$SideBarList$ctl00$SideBarButton&#39;,&#39;&#39;)\">step1</a></td>\r\n\t</tr>\r\n</table><table cellspacing=\"5\" cellpadding=\"5\">\r\n\t<tr>\r\n\t\t<td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepPreviousButton\" value=\"Previous\" id=\"MyWizard_StepNavigationTemplateContainerID_StepPreviousButton\" /></td><td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepNextButton\" value=\"Next\" id=\"MyWizard_StepNavigationTemplateContainerID_StepNextButton\" /></td>\r\n\t</tr>\r\n</table>Step";
+#else
+                       string origHtml = "<table id=\"MyWizard_SideBarList\" cellspacing=\"0\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td style=\"font-weight:bold;\"><a id=\"MyWizard_SideBarList_ctl00_SideBarButton_0\" href=\"javascript:__doPostBack(&#39;MyWizard$SideBarList$ctl00$SideBarButton&#39;,&#39;&#39;)\">step1</a></td>\r\n\t</tr>\r\n</table><table cellspacing=\"5\" cellpadding=\"5\">\r\n\t<tr>\r\n\t\t<td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepPreviousButton\" value=\"Previous\" id=\"MyWizard_StepNavigationTemplateContainerID_StepPreviousButton\" /></td><td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepNextButton\" value=\"Next\" id=\"MyWizard_StepNavigationTemplateContainerID_StepNextButton\" /></td>\r\n\t</tr>\r\n</table>Step";
+#endif
+                       string renderedHtml = HtmlDiff.GetControlFromPageHtml (result);
+                       Console.WriteLine (origHtml);
+                       Console.WriteLine ("----------------------------");
+                       Console.WriteLine (renderedHtml);
+                       
+                       Assert.AreEqual (origHtml, renderedHtml, "#A1");
+               }
+
+               [Test]
+               public void Wizard_LayoutTemplate_OptionalHeader ()
+               {
+                       WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
+                       t.UserData = "OptionalHeader_NoHeaderTemplate";
+                       string result = t.Run ();
+                       string renderedHtml = HtmlDiff.GetControlFromPageHtml (result);
+
+                       Assert.AreEqual (String.Empty, renderedHtml, "#A1");
+
+                       t.UserData = "OptionalHeader_WithHeaderTemplate";
+                       AssertExtensions.Throws<InvalidOperationException> (() => {
+                               result = t.Run ();
+                       }, "#A2");
+               }
+
+               [Test]
+               public void Wizard_LayoutTemplate_RenderHeader ()
+               {
+                       WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
+                       t.UserData = "RenderHeader";
+                       string result = t.Run ();
+                       string origHtml = "Header<table cellspacing=\"5\" cellpadding=\"5\">\r\n\t<tr>\r\n\t\t<td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepPreviousButton\" value=\"Previous\" id=\"MyWizard_StepNavigationTemplateContainerID_StepPreviousButton\" /></td><td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepNextButton\" value=\"Next\" id=\"MyWizard_StepNavigationTemplateContainerID_StepNextButton\" /></td>\r\n\t</tr>\r\n</table>Step";
+                       string renderedHtml = HtmlDiff.GetControlFromPageHtml (result);
+
+                       Assert.AreEqual (origHtml, renderedHtml, "#A1");
+
+                       t.UserData = "RenderHeader_InSpan";
+                       result = t.Run ();
+                       origHtml = "Header<table cellspacing=\"5\" cellpadding=\"5\">\r\n\t<tr>\r\n\t\t<td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepPreviousButton\" value=\"Previous\" id=\"MyWizard_StepNavigationTemplateContainerID_StepPreviousButton\" /></td><td align=\"right\"><input type=\"submit\" name=\"MyWizard$StepNavigationTemplateContainerID$StepNextButton\" value=\"Next\" id=\"MyWizard_StepNavigationTemplateContainerID_StepNextButton\" /></td>\r\n\t</tr>\r\n</table>Step";
+                       renderedHtml = HtmlDiff.GetControlFromPageHtml (result);
+                       Assert.AreEqual (origHtml, renderedHtml, "#A2");
+               }
+
+               [Test]
+               public void Wizard_LayoutTemplate_StepPlaceHolder ()
+               {
+                       WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
+                       t.UserData = "StepPlaceHolder";
+                       AssertExtensions.Throws<InvalidOperationException> (() => {
+                               string result = t.Run ();
+                       }, "#A1");
+               }
+
+               [Test]
+               public void Wizard_LayoutTemplate_NavigationPlaceHolder ()
+               {
+                       WebTest t = new WebTest (PageInvoker.CreateOnInit (LayoutTemplateRender));
+                       t.UserData = "NavigationPlaceHolder";
+                       AssertExtensions.Throws<InvalidOperationException> (() => {
+                               string result = t.Run ();
+                       }, "#A1");
+               }
+
+               public static void LayoutTemplateRender (Page p)
+               {
+                       var w = new Wizard ();
+                       w.ID = "MyWizard";
+                       WebTest curTest = WebTest.CurrentTest;
+                       string id = (string)curTest.UserData;
+
+                       switch (id) {
+                               case "Empty":
+                                       w.LayoutTemplate = new TestLayoutTemplate ();
+                                       break;
+
+                               case "OptionalSideBar_NoSideBar":
+                                       w.LayoutTemplate = new TestLayoutTemplate {
+                                               HasHeaderPlaceHolder = true,
+                                               HasNavigationPlaceHolder = true,
+                                               HasWizardStepPlaceHolder = true
+                                       };
+                                       w.DisplaySideBar = false;
+                                       break;
+
+                               case "OptionalSideBar_WithSideBar":
+                                       w.LayoutTemplate = new TestLayoutTemplate {
+                                               HasHeaderPlaceHolder = true,
+                                               HasNavigationPlaceHolder = true,
+                                               HasWizardStepPlaceHolder = true
+                                       };
+                                       w.DisplaySideBar = true;
+                                       break;
+
+                               case "RenderSideBar":
+                                       w.LayoutTemplate = new TestLayoutTemplate {
+                                               HasHeaderPlaceHolder = true,
+                                               HasNavigationPlaceHolder = true,
+                                               HasWizardStepPlaceHolder = true,
+                                               HasSideBarPlaceHolder = true
+                                       };
+                                       AddWizardStep (w, "Step", "step1");
+                                       break;
+
+                               case "OptionalHeader_NoHeaderTemplate":
+                                       w.LayoutTemplate = new TestLayoutTemplate {
+                                               HasNavigationPlaceHolder = true,
+                                               HasWizardStepPlaceHolder = true
+                                       };
+                                       w.DisplaySideBar = false;
+                                       break;
+
+                               case "OptionalHeader_WithHeaderTemplate":
+                                       w.LayoutTemplate = new TestLayoutTemplate {
+                                               HasNavigationPlaceHolder = true,
+                                               HasWizardStepPlaceHolder = true
+                                       };
+                                       w.HeaderTemplate = new TestHeaderTemplate ();
+                                       w.DisplaySideBar = false;
+                                       break;
+
+                               case "RenderHeader":
+                                       w.LayoutTemplate = new TestLayoutTemplate {
+                                               HasNavigationPlaceHolder = true,
+                                               HasWizardStepPlaceHolder = true,
+                                               HasHeaderPlaceHolder = true
+                                       };
+                                       w.HeaderTemplate = new TestHeaderTemplate ();
+                                       w.DisplaySideBar = false;
+                                       AddWizardStep (w, "Step", "step1");
+                                       break;
+
+                               case "RenderHeader_InSpan":
+                                       w.LayoutTemplate = new TestLayoutTemplate {
+                                               HasNavigationPlaceHolder = true,
+                                               HasWizardStepPlaceHolder = true,
+                                               HasHeaderPlaceHolder = true,
+                                               HeaderPlaceHolderType = typeof (TestHeaderSpan)
+                                       };
+                                       w.HeaderTemplate = new TestHeaderTemplate ();
+                                       w.DisplaySideBar = false;
+                                       AddWizardStep (w, "Step", "step1");
+                                       break;
+
+                               case "StepPlaceHolder":
+                                       w.LayoutTemplate = new TestLayoutTemplate {
+                                               HasNavigationPlaceHolder = true,
+                                       };
+                                       w.DisplaySideBar = false;
+                                       break;
+
+                               case "NavigationPlaceHolder":
+                                       w.LayoutTemplate = new TestLayoutTemplate {
+                                               HasWizardStepPlaceHolder = true,
+                                       };
+                                       w.DisplaySideBar = false;
+                                       break;
+
+                               default:
+                                       throw new InvalidOperationException ("Unknown id '" + id + "'");
+                       }
+
+                       p.Form.Controls.Add (new LiteralControl (HtmlDiff.BEGIN_TAG));
+                       p.Form.Controls.Add (w);
+                       p.Form.Controls.Add (new LiteralControl (HtmlDiff.END_TAG));
+               }
+
+               static void AddWizardStep (Wizard w, string stepText, string stepID, WizardStepType type = WizardStepType.Step)
+               {
+                       var ws = new WizardStep ();
+                       ws.ID = stepID;
+                       ws.StepType = type;
+                       ws.Controls.Add (new LiteralControl (stepText));
+
+                       w.WizardSteps.Add (ws);
+               }
+#endif
                [Test]
                [Category ("NunitWeb")]
                public void Wizard_RenderTestCompleteItem ()
@@ -1524,48 +1821,31 @@ namespace MonoTests.System.Web.UI.WebControls
                        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
+                       fr.Controls ["Wizard1$StartNavigationTemplateContainerID$CancelButton"].Value = "Cancel";
+
                        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");
@@ -1573,15 +1853,7 @@ namespace MonoTests.System.Web.UI.WebControls
                        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");
@@ -1600,42 +1872,24 @@ namespace MonoTests.System.Web.UI.WebControls
                        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");
@@ -1655,19 +1909,11 @@ namespace MonoTests.System.Web.UI.WebControls
 
                        //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$SideBarContainer$SideBarList$ctl01$SideBarButton";
                        fr.Controls ["__EVENTARGUMENT"].Value = "";
-#endif
                        t.Request = fr;
                        html = t.Run ();
                        Assert.AreEqual ("SideBarButtonClick", t.UserData.ToString (), "SideBarButton");
index 16e013810efd204fb198bd59c745febe9e78f092..9b8b74f81a2a83e784752e1534558857ab838661 100644 (file)
@@ -29,6 +29,8 @@ System.Web.UI.WebControls/IDataBoundListControl.cs
 System.Web.UI.WebControls/IFieldControl.cs
 System.Web.UI.WebControls/IRenderOuterTable.cs
 System.Web.UI.WebControls/RouteParameter.cs
+System.Web.UI.WebControls/WizardLayoutContainer.cs
+System.Web.UI.WebControls/WizardLayoutNavigationContainer.cs
 System.Web.Util/RequestValidationSource.cs
 System.Web.Util/RequestValidator.cs