improved partial rendering.
authorIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Mon, 2 Jul 2007 09:25:21 +0000 (09:25 -0000)
committerIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Mon, 2 Jul 2007 09:25:21 +0000 (09:25 -0000)
svn path=/trunk/mcs/; revision=81164

mcs/class/System.Web.Extensions/System.Web.UI/ScriptManager.cs
mcs/class/System.Web.Extensions/System.Web.UI/UpdatePanel.cs

index ca9c99f7a0d6bfdc45ad5ae483a9d28ca0592e9d..c8ec379a5bf619b214598d1f521e260d57f704c2 100644 (file)
@@ -84,6 +84,8 @@ namespace System.Web.UI
                int _asyncPostBackTimeout = 90;
                List<Control> _asyncPostBackControls;
                List<Control> _postBackControls;
+               List<UpdatePanel> _childUpdatePanels;
+               List<UpdatePanel> _panelsToRefresh;
                List<UpdatePanel> _updatePanels;
                ScriptReferenceCollection _scripts;
                bool _isInAsyncPostBack;
@@ -809,7 +811,7 @@ namespace System.Web.UI
                        return sb.ToString ();
                }
 
-               static string FormatListIDs (List<Control> list, bool useSingleQuote) {
+               static string FormatListIDs<T> (List<T> list, bool useSingleQuote) where T : Control {
                        if (list == null || list.Count == 0)
                                return null;
 
@@ -852,8 +854,18 @@ namespace System.Web.UI
                        WriteCallbackOutput (output, pageRedirect, null, redirectUrl);
                }
 
-               static internal void WriteCallbackPanel (TextWriter output, string clientID, StringBuilder panelOutput) {
-                       WriteCallbackOutput (output, updatePanel, clientID, panelOutput);
+               internal void WriteCallbackPanel (TextWriter output, UpdatePanel panel, StringBuilder panelOutput) {
+                       if (_panelsToRefresh == null)
+                               _panelsToRefresh = new List<UpdatePanel> ();
+                       _panelsToRefresh.Add (panel);
+
+                       WriteCallbackOutput (output, updatePanel, panel.ClientID, panelOutput);
+               }
+
+               internal void RegisterChildUpdatePanel (UpdatePanel updatePanel) {
+                       if (_childUpdatePanels == null)
+                               _childUpdatePanels = new List<UpdatePanel> ();
+                       _childUpdatePanels.Add (updatePanel);
                }
 
                static void WriteCallbackOutput (TextWriter output, string type, string name, object value) {
@@ -890,6 +902,8 @@ namespace System.Web.UI
                        WriteCallbackOutput (output, asyncPostBackControlIDs, null, FormatListIDs (_asyncPostBackControls, false));
                        WriteCallbackOutput (output, postBackControlIDs, null, FormatListIDs (_postBackControls, false));
                        WriteCallbackOutput (output, updatePanelIDs, null, FormatUpdatePanelIDs (_updatePanels, false));
+                       WriteCallbackOutput (output, childUpdatePanelIDs, null, FormatListIDs (_childUpdatePanels, false));
+                       WriteCallbackOutput (output, panelsToRefreshIDs, null, FormatListIDs (_panelsToRefresh, false));
                        WriteCallbackOutput (output, asyncPostBackTimeout, null, AsyncPostBackTimeout.ToString ());
                        WriteCallbackOutput (output, pageTitle, null, Page.Title);
 
index d0d9bedf925f120ac8c5d5d88243d6a43a2fc9ec..ba9f230849f6b7fbca3d29d907f9a1e17ec41e5d 100644 (file)
@@ -209,19 +209,26 @@ namespace System.Web.UI
                }
 
                protected override void RenderChildren (HtmlTextWriter writer) {
-                       if (ScriptManager.IsInAsyncPostBack && RequiresUpdate && !ScriptManager.IsInPartialRendering) {
-                               ScriptManager.IsInPartialRendering = true;
-                               HtmlTextWriter responseOutput = ((ScriptManager.AlternativeHtmlTextWriter) writer).ResponseOutput;
-                               StringBuilder sb = new StringBuilder ();
-                               HtmlTextWriter w = new HtmlTextWriter (new StringWriter (sb));
-                               base.RenderChildren (w);
-                               w.Flush ();
-
-                               ScriptManager.WriteCallbackPanel (responseOutput, ClientID, sb);
-                               for (int i = 0; i < sb.Length; i++)
-                                       writer.Write (sb [i]);
-
-                               ScriptManager.IsInPartialRendering = false;
+                       if (ScriptManager.IsInAsyncPostBack){
+                               if (RequiresUpdate && !ScriptManager.IsInPartialRendering) {
+                                       ScriptManager.IsInPartialRendering = true;
+                                       HtmlTextWriter responseOutput = ((ScriptManager.AlternativeHtmlTextWriter) writer).ResponseOutput;
+                                       StringBuilder sb = new StringBuilder ();
+                                       HtmlTextWriter w = new HtmlTextWriter (new StringWriter (sb));
+                                       base.RenderChildren (w);
+                                       w.Flush ();
+
+                                       ScriptManager.WriteCallbackPanel (responseOutput, this, sb);
+                                       for (int i = 0; i < sb.Length; i++)
+                                               writer.Write (sb [i]);
+
+                                       ScriptManager.IsInPartialRendering = false;
+                               }
+                               else {
+                                       if (ScriptManager.IsInPartialRendering)
+                                               ScriptManager.RegisterChildUpdatePanel (this);
+                                       base.RenderChildren (writer);
+                               }
                        }
                        else
                                base.RenderChildren (writer);