Переглянути джерело

* Login.cs: fixed CreateChildControls, throws exception if needed control not found
* LoginView.cs: fixed CreateChildControls, check templates for null

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

Vladimir Krasnov 19 роки тому
батько
коміт
cfaba47766

+ 6 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,9 @@
+2006-11-13  Vladimir Krasnov  <[email protected]>
+
+	* Login.cs: fixed CreateChildControls, throws exception if needed
+	control not found
+	* LoginView.cs: fixed CreateChildControls, check templates for null
+
 2006-11-13  Vladimir Krasnov  <[email protected]>
 
 	* Wizard.cs: fixed ActiveStepIndex property, fixed SideBar button

+ 4 - 1
mcs/class/System.Web/System.Web.UI.WebControls/Login.cs

@@ -1080,17 +1080,20 @@ namespace System.Web.UI.WebControls {
 				editable.Text = UserName;
 				editable.TextChanged += new EventHandler (UserName_TextChanged);
 			}
+			else
+				throw new HttpException ("LayoutTemplate does not contain an IEditableTextControl with ID UserName for the username.");
 
 			editable = container.PasswordTextBox as IEditableTextControl;
 
 			if (editable != null)
 				editable.TextChanged += new EventHandler (Password_TextChanged);
+			else
+				throw new HttpException ("LayoutTemplate does not contain an IEditableTextControl with ID Password for the password.");
 
 			ICheckBoxControl checkBox = container.RememberMeCheckBox as ICheckBoxControl;
 
 			if (checkBox != null)
 				checkBox.CheckedChanged += new EventHandler (RememberMe_CheckedChanged);
-			
 		}
 
 		protected override void LoadViewState (object savedState)

+ 13 - 9
mcs/class/System.Web/System.Web.UI.WebControls/LoginView.cs

@@ -121,17 +121,21 @@ namespace System.Web.UI.WebControls {
 			}
 		}
 
-		[MonoTODO("Handle RoleGroups")]
+		[MonoTODO ("Handle RoleGroups")]
 		protected internal override void CreateChildControls ()
 		{
-			Controls.Clear();
-			Control c = new Control();
-			if (IsAuthenticated)
-				LoggedInTemplate.InstantiateIn (c);
-			else
-				AnonymousTemplate.InstantiateIn (c);
-
-			Controls.Add(c);
+			Controls.Clear ();
+			Control c = new Control ();
+			if (IsAuthenticated) {
+				if (LoggedInTemplate != null)
+					LoggedInTemplate.InstantiateIn (c);
+			}
+			else {
+				if (AnonymousTemplate != null)
+					AnonymousTemplate.InstantiateIn (c);
+			}
+
+			Controls.Add (c);
 		}
 
 		public override void DataBind ()