فهرست منبع

2007-03-06 Igor Zelmanovich <[email protected]>

	* Style.cs: fixed:
	when AddAttributesToRender(System.Web.UI.HtmlTextWriter, WebControl) 
	is called, WebControl parameter is passed as argument to 
	FillStyleAttributes (CssStyleCollection, IUrlResolutionService) method.

svn path=/trunk/mcs/; revision=73798
Igor Zelmanovich 19 سال پیش
والد
کامیت
1105ed667d

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

@@ -1,3 +1,10 @@
+2007-03-06 Igor Zelmanovich <[email protected]>
+
+	* Style.cs: fixed:
+	when AddAttributesToRender(System.Web.UI.HtmlTextWriter, WebControl) 
+	is called, WebControl parameter is passed as argument to 
+	FillStyleAttributes (CssStyleCollection, IUrlResolutionService) method.
+
 2007-03-06 Igor Zelmanovich <[email protected]>
 
 	* DataList.cs:

+ 11 - 14
mcs/class/System.Web/System.Web.UI.WebControls/Style.cs

@@ -411,19 +411,21 @@ namespace System.Web.UI.WebControls {
 			{
 				if (CssClass.Length > 0)
 					writer.AddAttribute (HtmlTextWriterAttribute.Class, CssClass);
+#if NET_2_0
+				CssStyleCollection col = new CssStyleCollection (new StateBag ());
+				FillStyleAttributes (col, owner);
+				foreach (string key in col.Keys) {
+					writer.AddStyleAttribute (key, col [key]);
+				}
+#else
 				WriteStyleAttributes (writer);
+#endif
 			}
 		}
 
+#if ONLY_1_1
 		void WriteStyleAttributes (HtmlTextWriter writer) 
 		{
-#if NET_2_0
-			CssStyleCollection col = new CssStyleCollection (new StateBag ());
-			FillStyleAttributes (col, null);
-			foreach (string key in col.Keys) {
-				writer.AddStyleAttribute (key, col [key]);
-			}
-#else
 			string s;
 			Color		color;
 			BorderStyle	bs;
@@ -515,11 +517,11 @@ namespace System.Web.UI.WebControls {
 				if (s != "")
 					writer.AddStyleAttribute (HtmlTextWriterStyle.TextDecoration, s);
 			}
-#endif
 		}
+#endif
 
 #if NET_2_0
-		void FillStyleAttributes (CssStyleCollection attributes) 
+		protected virtual void FillStyleAttributes (CssStyleCollection attributes, IUrlResolutionService urlResolver)
 		{
 			Color		color;
 			BorderStyle	bs;
@@ -804,11 +806,6 @@ namespace System.Web.UI.WebControls {
 		#endregion	// IStateManager Properties & Methods
 
 #if NET_2_0
-		protected virtual void FillStyleAttributes (CssStyleCollection attributes, IUrlResolutionService urlResolver)
-		{
-			FillStyleAttributes (attributes);
-		}
-
 		internal void SetRegisteredCssClass (string name)
 		{
 			registered_class = name;

+ 31 - 0
mcs/class/System.Web/Test/System.Web.UI.WebControls/StyleTest.cs

@@ -731,5 +731,36 @@ namespace MonoTests.System.Web.UI.WebControls
 			s.AddAttributesToRender(writer);
 			// Figure out an order-independent way to verify rendered results
 		}
+#if NET_2_0
+		class PokerStyle : Style
+		{
+			public IUrlResolutionService UrlResolver;
+
+			protected override void FillStyleAttributes (CssStyleCollection attributes, IUrlResolutionService urlResolver)
+			{
+				UrlResolver = urlResolver;
+				base.FillStyleAttributes (attributes, urlResolver);
+			}
+		}
+		
+		class PokerWebControl : WebControl
+		{
+			protected override Style CreateControlStyle ()
+			{
+				return new PokerStyle ();
+			}
+		}
+
+		[Test]
+		public void FillStyleAttributes_UrlResolver ()
+		{
+			PokerWebControl c = new PokerWebControl ();
+			c.BackColor = Color.AliceBlue;
+			c.RenderControl (new HtmlTextWriter (new StringWriter ()));
+
+			Assert.AreEqual (c, ((PokerStyle) c.ControlStyle).UrlResolver);
+		}
+
+#endif
 	}
 }