2004-12-17 Lluis Sanchez Gual <lluis@novell.com>
authorLluis Sanchez <lluis@novell.com>
Fri, 17 Dec 2004 15:58:52 +0000 (15:58 -0000)
committerLluis Sanchez <lluis@novell.com>
Fri, 17 Dec 2004 15:58:52 +0000 (15:58 -0000)
* CssStyleCollection.cs: Make it work as a standalone collection.
* HtmlTextWriter.cs: Added static method for getting style names.

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

mcs/class/System.Web/System.Web.UI/ChangeLog
mcs/class/System.Web/System.Web.UI/CssStyleCollection.cs
mcs/class/System.Web/System.Web.UI/HtmlTextWriter.cs

index 2bc872e89451e7ae765ae8fc11f4d9a9797cc9a8..428a982c30045201ca5eedca5d782fbd0835ea70 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-17 Lluis Sanchez Gual <lluis@novell.com>
+
+       * CssStyleCollection.cs: Make it work as a standalone collection.
+       * HtmlTextWriter.cs: Added static method for getting style names.
+
 2004-12-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * ControlCollection.cs: fix off-by-one and store a null at the end to
index b49b5778fe6b3f6b62329e34879ed4b5c940a4fc..5db05ee5f85714a05ed52097eb5bf4272b93b5cd 100755 (executable)
@@ -40,6 +40,10 @@ namespace System.Web.UI {
                private StateBag bag;
                private StateBag style;
 
+               internal CssStyleCollection ()
+               {
+               }
+               
                internal CssStyleCollection (StateBag bag)
                {
                        this.bag = bag;
@@ -106,12 +110,24 @@ namespace System.Web.UI {
                public void Add (string key, string value)
                {
                        style [key] = value;
-                       bag ["style"] = BagToString ();
+                       if (bag != null)
+                               bag ["style"] = BagToString ();
+               }
+               
+#if NET_2_0
+               public
+#else
+               internal
+#endif
+               void Add (HtmlTextWriterStyle key, string value)
+               {
+                       Add (HtmlTextWriter.StaticGetStyleName (key), value);
                }
 
                public void Clear ()
                {
-                       bag.Remove ("style");
+                       if (bag != null)
+                               bag.Remove ("style");
                        style.Clear ();
                }
 
@@ -119,7 +135,8 @@ namespace System.Web.UI {
                {
                        if (style [key] != null) {
                                style.Remove (key);
-                               bag ["style"] = BagToString ();
+                               if (bag != null)
+                                       bag ["style"] = BagToString ();
                        }
                }
        }
index c8a754786e13349d46c508d03f25b7fd687419d7..c25c6eb2f76c745eaa893280d1e1e6dabf9dbe1b 100644 (file)
@@ -361,6 +361,10 @@ protected HtmlTextWriterStyle GetStyleKey(string styleName){
 }\r
 \r
 protected string GetStyleName(HtmlTextWriterStyle styleKey){\r
+       return StaticGetStyleName (styleKey);\r
+}\r
+\r
+internal static string StaticGetStyleName (HtmlTextWriterStyle styleKey){\r
        if ((int) styleKey >= 0 && (int) styleKey < HtmlTextWriter._styleNameLookupArray.Length)\r
                return HtmlTextWriter._styleNameLookupArray[(int) styleKey];\r
        return System.String.Empty;\r