Explorar o código

2010-07-13 Marek Habersack <[email protected]>

	* Control.cs: moved 4.0 ClientID code to a separate method, so
	that the ID_SET flag isn't set when necessary.

2010-07-13  Marek Habersack  <[email protected]>

	* Wizard.cs: wizard table doesn't contain any instances of
	HtmlAnchor or Image controls. Moved rendering of the skip link
	anchor to the TableCellNamingContainer class, which does that in
	RenderChildren by directly writing to the passed writer. Fixes 4.0
	rendering and all the failing Wizard tests.

svn path=/trunk/mcs/; revision=160304
Marek Habersack %!s(int64=15) %!d(string=hai) anos
pai
achega
3e86dae309

+ 8 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,11 @@
+2010-07-13  Marek Habersack  <[email protected]>
+
+	* Wizard.cs: wizard table doesn't contain any instances of
+	HtmlAnchor or Image controls. Moved rendering of the skip link
+	anchor to the TableCellNamingContainer class, which does that in
+	RenderChildren by directly writing to the passed writer. Fixes 4.0
+	rendering and all the failing Wizard tests.
+
 2010-07-08  Marek Habersack  <[email protected]>
 
 	* CheckBoxList.cs: RepeatLayout property update for new values of

+ 47 - 26
mcs/class/System.Web/System.Web.UI.WebControls/Wizard.cs

@@ -867,7 +867,7 @@ namespace System.Web.UI.WebControls
 
 				TableRow row = new TableRow ();
 
-				TableCellNamingContainer sideBarCell = new TableCellNamingContainer ();
+				TableCellNamingContainer sideBarCell = new TableCellNamingContainer (SkipLinkText, ClientID);
 				sideBarCell.ID = "SideBarContainer";
 				sideBarCell.ControlStyle.Height = Unit.Percentage (100);
 				CreateSideBar (sideBarCell);
@@ -1091,22 +1091,6 @@ namespace System.Web.UI.WebControls
 		void CreateSideBar (TableCell sideBarCell)
 		{
 			RegisterApplyStyle (sideBarCell, SideBarStyle);
-
-			if (SkipLinkText != "") {
-				System.Web.UI.HtmlControls.HtmlAnchor anchor = new System.Web.UI.HtmlControls.HtmlAnchor ();
-				anchor.HRef = "#" + ClientID + "_SkipLink";
-
-				Image img = new Image ();
-				ClientScriptManager csm = new ClientScriptManager (null);
-				img.ImageUrl = csm.GetWebResourceUrl (typeof (SiteMapPath), "transparent.gif");
-				img.Attributes.Add ("height", "0");
-				img.Attributes.Add ("width", "0");
-				img.AlternateText = SkipLinkText;
-
-				anchor.Controls.Add (img);
-				sideBarCell.Controls.Add (anchor);
-			}
-
 			if (sideBarTemplate != null) {
 				sideBarTemplate.InstantiateIn (sideBarCell);
 				stepDatalist = sideBarCell.FindControl (DataListID) as DataList;
@@ -1121,12 +1105,6 @@ namespace System.Web.UI.WebControls
 				sideBarCell.Controls.Add (stepDatalist);
 			}
 
-			if (SkipLinkText != "") {
-				System.Web.UI.HtmlControls.HtmlAnchor anchor = new System.Web.UI.HtmlControls.HtmlAnchor ();
-				anchor.ID = "SkipLink";
-				sideBarCell.Controls.Add (anchor);
-			}
-
 			stepDatalist.ItemCommand += new DataListCommandEventHandler (StepDatalistItemCommand);
 			stepDatalist.CellSpacing = 0;
 			stepDatalist.DataSource = WizardSteps;
@@ -1476,14 +1454,57 @@ namespace System.Web.UI.WebControls
 			}
 		}
 
-		class TableCellNamingContainer : TableCell, INamingContainer, INonBindingContainer
+		sealed class TableCellNamingContainer : TableCell, INamingContainer, INonBindingContainer
 		{
-			public TableCellNamingContainer ()
+			string skipLinkText;
+			string clientId;
+			bool haveSkipLink;
+			
+			protected internal override void RenderChildren (HtmlTextWriter writer)
+			{
+				if (haveSkipLink) {
+					// <a href="#ID_SkipLink">
+					writer.AddAttribute (HtmlTextWriterAttribute.Href, "#" + clientId + "_SkipLink");
+					writer.RenderBeginTag (HtmlTextWriterTag.A);
+
+					// <img alt="" height="0" width="0" src="" style="border-width:0px;"/>
+					writer.AddAttribute (HtmlTextWriterAttribute.Alt, skipLinkText);
+					writer.AddAttribute (HtmlTextWriterAttribute.Height, "0");
+					writer.AddAttribute (HtmlTextWriterAttribute.Width, "0");
+
+					Page page = Page;
+					ClientScriptManager csm;
+					
+					if (page != null)
+						csm = page.ClientScript;
+					else
+						csm = new ClientScriptManager (null);
+					writer.AddAttribute (HtmlTextWriterAttribute.Src, csm.GetWebResourceUrl (typeof (SiteMapPath), "transparent.gif"));
+					writer.AddStyleAttribute (HtmlTextWriterStyle.BorderWidth, "0px");
+					writer.RenderBeginTag (HtmlTextWriterTag.Img);
+					writer.RenderEndTag ();
+					
+					writer.RenderEndTag (); // </a>
+				}
+				
+				base.RenderChildren (writer);
+
+				if (haveSkipLink) {
+					writer.AddAttribute (HtmlTextWriterAttribute.Id, "SkipLink");
+					writer.RenderBeginTag (HtmlTextWriterTag.A);
+					writer.RenderEndTag ();
+				}
+			}
+			
+			public TableCellNamingContainer (string skipLinkText, string clientId)
 			{
+				this.skipLinkText = skipLinkText;
+				this.clientId = clientId;
+				this.haveSkipLink = !String.IsNullOrEmpty (skipLinkText);
 			}
 		}
 
-		class SideBarButtonTemplate: ITemplate
+		sealed class SideBarButtonTemplate: ITemplate
 		{
 			Wizard wizard;
 			

+ 5 - 0
mcs/class/System.Web/System.Web.UI/ChangeLog

@@ -1,3 +1,8 @@
+2010-07-13  Marek Habersack  <[email protected]>
+
+	* Control.cs: moved 4.0 ClientID code to a separate method, so
+	that the ID_SET flag isn't set when necessary.
+
 2010-07-10  Marek Habersack  <[email protected]>
 
 	* Control.cs: when setting ClientIDMode remember the value when

+ 21 - 16
mcs/class/System.Web/System.Web.UI/Control.cs

@@ -219,21 +219,7 @@ namespace System.Web.UI
 				if (clientID != null)
 					return clientID;
 #if NET_4_0
-				switch (EffectiveClientIDMode) {
-					case ClientIDMode.AutoID:
-						clientID = UniqueID2ClientID (UniqueID);
-						break;
-
-					case ClientIDMode.Predictable:
-						EnsureID ();
-						clientID = GeneratePredictableClientID ();
-						break;
-
-					case ClientIDMode.Static:
-						EnsureID ();
-						clientID = ID;
-						break;
-				}
+				clientID = GetClientID ();
 #else
 				clientID = UniqueID2ClientID (UniqueID);
 #endif				
@@ -368,6 +354,25 @@ namespace System.Web.UI
 			for (int i = 0; i < _controls.Count; i++)
 				_controls [i].ClearEffectiveClientIDMode ();
 		}
+
+		string GetClientID ()
+		{
+			switch (EffectiveClientIDMode) {
+				case ClientIDMode.AutoID:
+					return UniqueID2ClientID (UniqueID);
+
+				case ClientIDMode.Predictable:
+					EnsureID ();
+					return GeneratePredictableClientID ();
+
+				case ClientIDMode.Static:
+					EnsureID ();
+					return ID;
+
+				default:
+					throw new InvalidOperationException ("Unsupported ClientIDMode value.");
+			}
+		}
 		
 		string GeneratePredictableClientID ()
 		{
@@ -386,7 +391,7 @@ namespace System.Web.UI
 			if (container != null && container != Page) {
 				string containerID = container.ID;
 				if (!String.IsNullOrEmpty (containerID)) {
-					sb.Append (container.ClientID);
+					sb.Append (container.GetClientID ());
 					sb.Append (separator);
 				} else {
 					sb.Append (container.GeneratePredictableClientID ());

+ 0 - 4
mcs/class/System.Web/Test/System.Web.UI.WebControls/WizardStepBaseTest.cs

@@ -222,10 +222,6 @@ namespace MonoTests.System.Web.UI.WebControls
 			string origin = "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td style=\"height:100%;\"><a href=\"#ctl01_SkipLink\"><img alt=\"Skip Navigation Links.\" height=\"0\" width=\"0\" src=\"/NunitWeb/WebResource.axd?d=4RHYfeNnynkXiM59uthjZg2&amp;t=633802729995006876\" style=\"border-width:0px;\" /></a><table id=\"ctl01_SideBarContainer_SideBarList\" cellspacing=\"0\" border=\"0\" style=\"border-collapse:collapse;\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td style=\"font-weight:bold;\"><a id=\"ctl01_SideBarContainer_SideBarList_ctl00_SideBarButton\" href=\"javascript:__doPostBack('ctl01$SideBarContainer$SideBarList$ctl00$SideBarButton','')\">my_title</a></td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td><a id=\"ctl01_SideBarContainer_SideBarList_ctl01_SideBarButton\" href=\"javascript:__doPostBack('ctl01$SideBarContainer$SideBarList$ctl01$SideBarButton','')\">my_title_2</a></td>\r\n\t\t\t</tr>\r\n\t\t</table><a id=\"ctl01_SkipLink\"></a></td><td style=\"height:100%;\"><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"height:100%;width:100%;border-collapse:collapse;\">\r\n\t\t\t<tr style=\"height:100%;\">\r\n\t\t\t\t<td>123</td>\r\n\t\t\t</tr><tr>\r\n\t\t\t\t<td align=\"right\"><table cellspacing=\"5\" cellpadding=\"5\" border=\"0\">\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td align=\"right\"><input type=\"submit\" name=\"ctl01$StartNavigationTemplateContainerID$StartNextButton\" value=\"Next\" id=\"ctl01_StartNavigationTemplateContainerID_StartNextButton\" /></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</table></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table>";
 #endif
 			string renderedHtml = HtmlDiff.GetControlFromPageHtml (html);
-			Console.WriteLine (origin);
-			Console.WriteLine ("------------------------");
-			Console.WriteLine (renderedHtml);
-			
 			HtmlDiff.AssertAreEqual (origin, renderedHtml, "BaseRender");
 			if (html.IndexOf ("my_title") < 0)
 				Assert.Fail ("WizardStepBase title not rendered");

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 29 - 1
mcs/class/System.Web/Test/System.Web.UI.WebControls/WizardTest.cs


Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio