Author: igorz
Date: 2007-06-21 08:50:28 -0400 (Thu, 21 Jun 2007)
New Revision: 80455

Modified:
   trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManager.cs
Log:
Implemented RegisterHiddenField

Modified: trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManager.cs
===================================================================
--- trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManager.cs        
2007-06-21 12:50:21 UTC (rev 80454)
+++ trunk/mcs/class/System.Web.Extensions/System.Web.UI/ScriptManager.cs        
2007-06-21 12:50:28 UTC (rev 80455)
@@ -92,6 +92,7 @@
                ScriptEntry _clientScriptBlocks;
                ScriptEntry _startupScriptBlocks;
                List<ArrayDeclaration> _arrayDeclarations;
+               Hashtable _hiddenFields;
 
                [DefaultValue (true)]
                [Category ("Behavior")]
@@ -561,14 +562,26 @@
 
                public static void RegisterHiddenField (Control control, string 
hiddenFieldName, string hiddenFieldInitialValue)
                {
-                       throw new NotImplementedException ();
+                       RegisterHiddenField (control.Page, hiddenFieldName, 
hiddenFieldInitialValue);
                }
 
                public static void RegisterHiddenField (Page page, string 
hiddenFieldName, string hiddenFieldInitialValue)
                {
-                       throw new NotImplementedException ();
+                       ScriptManager sm = GetCurrent (page);
+                       if (sm.IsInAsyncPostBack)
+                               sm.RegisterHiddenField (hiddenFieldName, 
hiddenFieldInitialValue);
+                       else
+                               page.ClientScript.RegisterHiddenField 
(hiddenFieldName, hiddenFieldInitialValue);
                }
 
+               void RegisterHiddenField (string hiddenFieldName, string 
hiddenFieldInitialValue) {
+                       if (_hiddenFields == null)
+                               _hiddenFields = new Hashtable ();
+
+                       if (!_hiddenFields.ContainsKey (hiddenFieldName))
+                               _hiddenFields.Add (hiddenFieldName, 
hiddenFieldInitialValue);
+               }
+
                public static void RegisterOnSubmitStatement (Control control, 
Type type, string key, string script)
                {
                        throw new NotImplementedException ();
@@ -744,6 +757,7 @@
                        WriteArrayDeclarations (output);
                        WriteScriptBlocks (output, _clientScriptBlocks);
                        WriteScriptBlocks (output, _startupScriptBlocks);
+                       WriteHiddenFields (output);
                }
 
                void WriteArrayDeclarations (HtmlTextWriter writer) {
@@ -773,6 +787,15 @@
                        }
                }
 
+               void WriteHiddenFields (HtmlTextWriter output) {
+                       if (_hiddenFields == null)
+                               return;
+                       foreach (string key in _hiddenFields.Keys) {
+                               string value = _hiddenFields [key] as string;
+                               WriteCallbackOutput (output, hiddenField, key, 
value);
+                       }
+               }
+
                [MonoTODO()]
                static string SerializeScriptBlock (ScriptEntry scriptList) {
                        throw new InvalidOperationException (String.Format 
("The script tag registered for type '{0}' and key '{1}' has invalid characters 
outside of the script tags: {2}. Only properly formatted script tags can be 
registered.", scriptList.Type, scriptList.Key, scriptList.Script));

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to