Author: igorz
Date: 2007-01-04 07:45:19 -0500 (Thu, 04 Jan 2007)
New Revision: 70469
Modified:
trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataBoundControl.cs
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/DataBoundControlTest.cs
Log:
2006-01-04 Igor Zelmanovich <[EMAIL PROTECTED]>
* DataBoundControl.cs: fixed Init flow.
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2007-01-04 12:43:54 UTC (rev 70468)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2007-01-04 12:45:19 UTC (rev 70469)
@@ -1,3 +1,7 @@
+2006-01-04 Igor Zelmanovich <[EMAIL PROTECTED]>
+
+ * DataBoundControl.cs: fixed Init flow.
+
2007-01-4 Adar Wesley <[EMAIL PROTECTED]>
* RadioButtonList.cs: Implemented properties of IRepeatInfoUser as
public virtual
Modified:
trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataBoundControl.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataBoundControl.cs
2007-01-04 12:43:54 UTC (rev 70468)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataBoundControl.cs
2007-01-04 12:45:19 UTC (rev 70469)
@@ -121,9 +121,22 @@
RequiresDataBinding = true;
}
+ // MSDN: The OnPagePreLoad method is overridden by the
DataBoundControl class
+ // to set the BaseDataBoundControl.RequiresDataBinding property
to true in
+ // cases where the HTTP request is a postback and view state is
enabled but
+ // the data-bound control has not yet been bound.
protected override void OnPagePreLoad (object sender, EventArgs
e)
{
base.OnPagePreLoad (sender, e);
+
+ Initialize ();
+ }
+
+ private void Initialize ()
+ {
+ if (!Page.IsPostBack || (IsViewStateEnabled &&
!IsDataBound))
+ RequiresDataBinding = true;
+
UpdateViewData ();
}
@@ -143,13 +156,14 @@
protected internal override void OnLoad (EventArgs e)
{
- if (!Page.IsPostBack || (IsViewStateEnabled &&
!IsDataBound))
- RequiresDataBinding = true;
+ if (!Initialized) {
+
+ Initialize ();
- // MSDN: The ConfirmInitState method sets the
initialized state of the data-bound
- // control. The method is called by the
DataBoundControl class in its OnLoad method.
- ConfirmInitState ();
-
+ // MSDN: The ConfirmInitState method sets the
initialized state of the data-bound
+ // control. The method is called by the
DataBoundControl class in its OnLoad method.
+ ConfirmInitState ();
+ }
base.OnLoad(e);
}
Modified: trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
2007-01-04 12:43:54 UTC (rev 70468)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
2007-01-04 12:45:19 UTC (rev 70469)
@@ -1,3 +1,7 @@
+2007-01-04 Igor Zelmanovich <[EMAIL PROTECTED]>
+
+ * DataBoundControlTest.cs: new tests were added.
+
2007-01-03 Igor Zelmanovich <[EMAIL PROTECTED]>
* FormViewTest.cs: new tests were added.
Modified:
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/DataBoundControlTest.cs
===================================================================
---
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/DataBoundControlTest.cs
2007-01-04 12:43:54 UTC (rev 70468)
+++
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/DataBoundControlTest.cs
2007-01-04 12:45:19 UTC (rev 70469)
@@ -60,6 +60,16 @@
{
return Initialized;
}
+
+ public bool GetRequiresDataBinding ()
+ {
+ return RequiresDataBinding;
+ }
+
+ public void SetRequiresDataBinding (bool value)
+ {
+ RequiresDataBinding = value;
+ }
}
class MyDataBoundControl : DataBoundControl
@@ -231,13 +241,48 @@
p.Form.Controls.Clear ();
p.Form.Controls.Add (c);
Assert.IsFalse (c.GetInitialized (),
"Initialized_Load");
+ Assert.IsFalse (c.GetRequiresDataBinding (),
"RequiresDataBinding_Load");
}
public static void Initialized_PreRender (Page p)
{
Poker c = (Poker) p.Form.Controls [0];
Assert.IsTrue (c.GetInitialized (),
"Initialized_PreRender");
+ Assert.IsTrue (c.GetRequiresDataBinding (),
"RequiresDataBinding_PreRender");
}
+
+ [Test]
+ [Category ("NunitWeb")]
+ public void Initialized2 () {
+ WebTest t = new WebTest ();
+ PageDelegates pd = new PageDelegates ();
+ pd.Init = Initialized2_Init;
+ pd.Load = Initialized2_Load;
+ pd.PreRenderComplete = Initialized2_PreRender;
+ t.Invoker = new PageInvoker (pd);
+ t.Run ();
+ }
+
+ public static void Initialized2_Init (Page p) {
+ Poker c = new Poker ();
+ p.Form.Controls.Clear ();
+ p.Form.Controls.Add (c);
+ Assert.IsFalse (c.GetInitialized (),
"Initialized_Init");
+ Assert.IsFalse (c.GetRequiresDataBinding (),
"RequiresDataBinding_Init");
+ }
+
+ public static void Initialized2_Load (Page p) {
+ Poker c = (Poker) p.Form.Controls [0];
+ Assert.IsTrue (c.GetInitialized (), "Initialized_Load");
+ Assert.IsTrue (c.GetRequiresDataBinding (),
"RequiresDataBinding_Load");
+ c.SetRequiresDataBinding (false);
+ }
+
+ public static void Initialized2_PreRender (Page p) {
+ Poker c = (Poker) p.Form.Controls [0];
+ Assert.IsTrue (c.GetInitialized (),
"Initialized_PreRender");
+ Assert.IsFalse (c.GetRequiresDataBinding (),
"RequiresDataBinding_PreRender");
+ }
}
}
#endif
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches