2007-03-06 Igor Zelmanovich <igorz@mainsoft.com>
authorIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Tue, 6 Mar 2007 10:14:29 +0000 (10:14 -0000)
committerIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Tue, 6 Mar 2007 10:14:29 +0000 (10:14 -0000)
* 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

mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/System.Web.UI.WebControls/Style.cs
mcs/class/System.Web/Test/System.Web.UI.WebControls/StyleTest.cs

index 7642fa1ea77d17e52f73a80b7692df8b18b2f856..cf5590c305b07481ad1386349bf52f11934cd71e 100644 (file)
@@ -1,3 +1,10 @@
+2007-03-06 Igor Zelmanovich <igorz@mainsoft.com>
+
+       * 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 <igorz@mainsoft.com>
 
        * DataList.cs:
index fd08ad4d552978af661a5afb23303757e8d0c51f..8febbc2b68700b4e6a16b52276dbf35d2a08c192 100644 (file)
@@ -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;
index b3bf32e3c3e8e89535e8581a5d4bfc5fcfda5aa3..1d32d84a73778f69bf74bc633511f0c2d672c46a 100644 (file)
@@ -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
        }
 }