Author: igorz
Date: 2006-12-11 03:36:17 -0500 (Mon, 11 Dec 2006)
New Revision: 69301
Modified:
trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
trunk/mcs/class/System.Web/System.Web.UI/Page.cs
trunk/mcs/class/System.Web/Test/System.Web.UI/ChangeLog
trunk/mcs/class/System.Web/Test/System.Web.UI/PageTest.cs
Log:
2006-12-11 Igor Zelmanovich <[EMAIL PROTECTED]>
* Page.cs: fixed and optimized ProcessPostData
The "second try" used for controls that created at OnLoad.
fixed for controls that use RgisterRequeresPostBack to handle post data.
Modified: trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/ChangeLog 2006-12-11 08:12:16 UTC
(rev 69300)
+++ trunk/mcs/class/System.Web/System.Web.UI/ChangeLog 2006-12-11 08:36:17 UTC
(rev 69301)
@@ -1,3 +1,9 @@
+2006-12-11 Igor Zelmanovich <[EMAIL PROTECTED]>
+
+ * Page.cs: fixed and optimized ProcessPostData
+ The "second try" used for controls that created at OnLoad.
+ fixed for controls that use RgisterRequeresPostBack to handle post data.
+
2006-11-29 Igor Zelmanovich <[EMAIL PROTECTED]>
* Page.cs: The specified theme must exist as either an application
theme.
Modified: trunk/mcs/class/System.Web/System.Web.UI/Page.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/Page.cs 2006-12-11 08:12:16 UTC
(rev 69300)
+++ trunk/mcs/class/System.Web/System.Web.UI/Page.cs 2006-12-11 08:36:17 UTC
(rev 69301)
@@ -1012,11 +1012,10 @@
private void ProcessPostData (NameValueCollection data, bool second)
{
- if (data == null)
- return;
+ if (!second)
+ _requiresPostBackCopy = (_requiresPostBack == null) ?
null : (ArrayList) _requiresPostBack.Clone ();
- if (_requiresPostBackCopy == null && _requiresPostBack != null)
- _requiresPostBackCopy = (ArrayList)
_requiresPostBack.Clone ();
+ if (data != null) {
Hashtable used = new Hashtable ();
foreach (string id in data.AllKeys){
@@ -1057,6 +1056,7 @@
secondPostData.Add (real_id, data [id]);
}
}
+ }
ArrayList list1 = null;
if (_requiresPostBackCopy != null &&
_requiresPostBackCopy.Count > 0) {
@@ -1071,14 +1071,16 @@
requiresPostDataChanged.Add
(pbdh);
}
- } else if (second) {
+ } else if (!second) {
if (list1 == null)
list1 = new ArrayList ();
list1.Add (id);
}
}
}
- _requiresPostBack = list1;
+ _requiresPostBackCopy = second ? null : list1;
+ if (second)
+ secondPostData = null;
}
[EditorBrowsable (EditorBrowsableState.Never)]
@@ -1410,6 +1412,9 @@
if (_requiresPostBack == null)
_requiresPostBack = new ArrayList ();
+ if (_requiresPostBack.Contains (control.UniqueID))
+ return;
+
_requiresPostBack.Add (control.UniqueID);
}
Modified: trunk/mcs/class/System.Web/Test/System.Web.UI/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI/ChangeLog 2006-12-11
08:12:16 UTC (rev 69300)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI/ChangeLog 2006-12-11
08:36:17 UTC (rev 69301)
@@ -1,3 +1,7 @@
+2006-12-11 Igor Zelmanovich <[EMAIL PROTECTED]>
+
+ * PageTest.cs: added test.
+
2006-12-07 Igor Zelmanovich <[EMAIL PROTECTED]>
* PageTest.cs: fixed NunitWeb tests.
Modified: trunk/mcs/class/System.Web/Test/System.Web.UI/PageTest.cs
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI/PageTest.cs 2006-12-11
08:12:16 UTC (rev 69300)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI/PageTest.cs 2006-12-11
08:36:17 UTC (rev 69301)
@@ -1037,6 +1037,54 @@
#endregion
#endif
+ [Test]
+ [Category ("NunitWeb")]
+ public void ProcessPostData_Second_Try () //Just flow and not
implementation detail
+ {
+ WebTest t = new WebTest (PageInvoker.CreateOnLoad
(ProcessPostData_Second_Try_Load));
+ string html = t.Run ();
+ FormRequest fr = new FormRequest (t.Response, "form1");
+ fr.Controls.Add ("__EVENTTARGET");
+ fr.Controls.Add ("__EVENTARGUMENT");
+ fr.Controls ["__EVENTTARGET"].Value = "__Page";
+ fr.Controls ["__EVENTARGUMENT"].Value = "";
+ t.Request = fr;
+ t.Run ();
+
+ Assert.AreEqual
("CustomPostBackDataHandler_LoadPostData", t.UserData, "User data does not been
created fail");
+ }
+
+ public static void ProcessPostData_Second_Try_Load (Page p)
+ {
+ CustomPostBackDataHandler c = new
CustomPostBackDataHandler ();
+ c.ID = "CustomPostBackDataHandler1";
+ p.Form.Controls.Add (c);
+ }
+
+ class CustomPostBackDataHandler : WebControl,
IPostBackDataHandler
+ {
+ protected override void OnInit (EventArgs e)
+ {
+ base.OnInit (e);
+ Page.RegisterRequiresPostBack (this);
+ }
+
+ #region IPostBackDataHandler Members
+
+ public bool LoadPostData (string postDataKey,
global::System.Collections.Specialized.NameValueCollection postCollection)
+ {
+ WebTest.CurrentTest.UserData =
"CustomPostBackDataHandler_LoadPostData";
+ return false;
+ }
+
+ public void RaisePostDataChangedEvent ()
+ {
+ }
+
+ #endregion
+ }
+
+
[TestFixtureTearDown]
public void TearDown ()
{
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches