2 // Tests for System.Web.UI.Control
5 // Peter Dennis Bartok (pbartok@novell.com)
6 // Gonzalo Paniagua Javier (gonzalo@novell.com)
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using NUnit.Framework;
34 using System.Collections;
37 using System.Globalization;
40 using System.Web.UI.WebControls;
41 using MonoTests.SystemWeb.Framework;
42 using MonoTests.stand_alone.WebHarness;
43 using MonoTests.Common;
45 using System.Web.UI.Adapters;
47 using System.Web.Routing;
49 namespace MonoTests.System.Web.UI
52 public class ControlTest
55 public void DataBindingInterfaceTest ()
58 DataBindingCollection db;
61 Assert.AreEqual (false, ((IDataBindingsAccessor) c).HasDataBindings, "DB1");
62 db = ((IDataBindingsAccessor) c).DataBindings;
63 Assert.IsNotNull (db, "DB2");
64 Assert.AreEqual (false, ((IDataBindingsAccessor) c).HasDataBindings, "DB3");
65 db.Add (new DataBinding ("property", typeof (bool), "expression"));
66 Assert.AreEqual (true, ((IDataBindingsAccessor) c).HasDataBindings);
70 public void FindControl_NamingContainer ()
72 Control topControl = new NamingContainer ();
73 topControl.ID = "top";
75 Control controlLevel1A = new Control ();
76 controlLevel1A.ID = "Level1#A";
77 topControl.Controls.Add (controlLevel1A);
79 Control controlLevel1B = new Control ();
80 controlLevel1B.ID = "Level1#B";
81 topControl.Controls.Add (controlLevel1B);
83 Control controlLevel2AA = new Control ();
84 controlLevel2AA.ID = "Level2#AA";
85 controlLevel1A.Controls.Add (controlLevel2AA);
87 Control controlLevel2AB = new Control ();
88 controlLevel2AB.ID = "Level2#AB";
89 controlLevel1A.Controls.Add (controlLevel2AB);
91 Control foundControl = topControl.FindControl ("Level1#A");
92 Assert.IsNotNull (foundControl, "#A1");
93 Assert.AreSame (controlLevel1A, foundControl, "#A2");
95 foundControl = topControl.FindControl ("LEVEL1#B");
96 Assert.IsNotNull (foundControl, "#B1");
97 Assert.AreSame (controlLevel1B, foundControl, "#B2");
99 foundControl = topControl.FindControl ("LeVeL2#AB");
100 Assert.IsNotNull (foundControl, "#C1");
101 Assert.AreSame (controlLevel2AB, foundControl, "#C2");
103 foundControl = topControl.FindControl ("doesnotexist");
104 Assert.IsNull (foundControl, "#D1");
105 foundControl = topControl.FindControl ("top");
106 Assert.IsNull (foundControl, "#D2");
108 foundControl = controlLevel1A.FindControl ("Level2#AA");
109 Assert.IsNotNull (foundControl, "#E1");
110 Assert.AreSame (controlLevel2AA, foundControl, "#E2");
112 foundControl = controlLevel1A.FindControl ("LEveL2#ab");
113 Assert.IsNotNull (foundControl, "#F1");
114 Assert.AreSame (controlLevel2AB, foundControl, "#F2");
118 public void UniqueID1 ()
121 Control nc = new MyNC ();
122 Assert.IsNull (nc.UniqueID, "nulltest");
126 public void UniqueID1_1 () {
128 Control nc = new MyNC ();
129 Page p = new Page ();
131 Assert.IsNotNull (nc.UniqueID, "notnull");
135 public void UniqueID2 ()
138 Control nc = new MyNC ();
139 Control nc2 = new MyNC ();
140 nc2.Controls.Add (nc);
141 Assert.IsNotNull (nc.UniqueID, "notnull");
142 Assert.IsTrue (nc.UniqueID.IndexOfAny (new char[] { ':', '$' }) == -1, "separator");
146 public void UniqueID2_1 () {
148 Control nc = new MyNC ();
149 Control nc2 = new MyNC ();
150 nc2.Controls.Add (nc);
151 Page p = new Page ();
152 p.Controls.Add (nc2);
153 Assert.IsNotNull (nc.UniqueID, "notnull");
154 Assert.IsTrue (nc.UniqueID.IndexOfAny (new char [] { ':', '$' }) != -1, "separator");
158 public void UniqueID3 ()
161 Control control = new Control ();
162 Control nc = new MyNC ();
164 control.Controls.Add (nc);
165 Assert.IsNull (nc.UniqueID, "null");
169 public void UniqueID4 ()
172 Control control = new Control ();
173 Control nc = new MyNC ();
175 nc.Controls.Add (control);
176 Assert.IsNotNull (control.UniqueID, "notnull");
180 public void UniqueID5 ()
183 Control control = new Control ();
184 Control nc = new MyNC ();
185 Control nc2 = new MyNC ();
187 nc2.Controls.Add (nc);
188 nc.Controls.Add (control);
189 Assert.IsNotNull (control.UniqueID, "notnull");
190 Assert.IsNull (nc2.ID, "null-1");
191 Assert.IsNull (nc.ID, "null-2");
192 Assert.IsTrue (-1 != control.UniqueID.IndexOfAny (new char[] { ':', '$' }), "separator");
196 public void UniqueID6 () {
198 Control nc = new MyNC ();
199 Page p = new Page ();
201 Assert.IsNotNull (nc.UniqueID, "notnull");
203 Control c1 = new Control ();
204 Control c2 = new Control ();
205 nc.Controls.Add (c1);
206 nc.Controls.Add (c2);
207 string uid1_1 = c1.UniqueID;
208 string uid2_1 = c2.UniqueID;
210 nc.Controls.Clear ();
212 Assert.IsNull (c1.UniqueID);
213 Assert.IsNull (c2.UniqueID);
215 // ad in another order
216 nc.Controls.Add (c2);
217 nc.Controls.Add (c1);
218 string uid1_2 = c1.UniqueID;
219 string uid2_2 = c2.UniqueID;
221 Assert.IsFalse (uid1_1 == uid1_2);
222 Assert.IsFalse (uid2_1 == uid2_2);
223 Assert.AreEqual (uid1_1, uid2_2);
224 Assert.AreEqual (uid2_1, uid1_2);
226 nc.Controls.Remove (c1);
227 nc.Controls.Add (c1);
228 string uid1_3 = c1.UniqueID;
229 Assert.IsFalse (uid1_3 == uid1_2, "id was not reset");
231 EnsureIDControl c3 = new EnsureIDControl ();
232 nc.Controls.Add (c3);
233 string uid3_1 = c3.UniqueID;
235 Assert.IsNotNull (c3.ID);
236 nc.Controls.Remove (c3);
237 nc.Controls.Add (c3);
238 string uid3_2 = c3.UniqueID;
239 Assert.IsNull (c3.ID);
240 Assert.IsFalse (uid3_1 == uid3_2, "id was not reset");
244 public void ClientID ()
247 Control control = new Control ();
248 Control nc = new MyNC ();
249 Control nc2 = new MyNC ();
250 Control nc3 = new MyNC ();
252 nc3.Controls.Add (nc2);
253 nc2.Controls.Add (nc);
254 nc.Controls.Add (control);
255 string expected = "ctl00_ctl00_ctl00";
256 Assert.AreEqual (expected, control.ClientID, "ClientID");
259 // From bug #76919: Control uses _controls instead of
260 // Controls when RenderChildren is called.
262 public void Controls1 ()
264 DerivedControl derived = new DerivedControl ();
265 derived.Controls.Add (new LiteralControl ("hola"));
266 StringWriter sw = new StringWriter ();
267 HtmlTextWriter htw = new HtmlTextWriter (sw);
268 derived.RenderControl (htw);
269 string result = sw.ToString ();
270 Assert.AreEqual ("", result, "#01");
273 [Test] // Bug #471305
274 [Category ("NunitWeb")]
275 public void NoDoubleOnInitOnRemoveAdd ()
277 WebTest.CopyResource (GetType (), "NoDoubleOnInitOnRemoveAdd.aspx", "NoDoubleOnInitOnRemoveAdd.aspx");
278 WebTest.CopyResource (GetType (), "NoDoubleOnInitOnRemoveAdd.aspx.cs", "NoDoubleOnInitOnRemoveAdd.aspx.cs");
279 WebTest t = new WebTest ("NoDoubleOnInitOnRemoveAdd.aspx");
280 string html = t.Run ();
282 Assert.AreEqual (-1, html.IndexOf ("<span>label</span><span>label</span>"), "#A1");
286 [Category("NunitWeb")]
287 public void AppRelativeTemplateSourceDirectory ()
289 new WebTest(PageInvoker.CreateOnLoad(AppRelativeTemplateSourceDirectory_Load)).Run();
292 public static void AppRelativeTemplateSourceDirectory_Load(Page p)
294 Control ctrl = new Control();
295 Assert.AreEqual("~/", ctrl.AppRelativeTemplateSourceDirectory, "AppRelativeTemplateSourceDirectory#1");
296 ctrl.AppRelativeTemplateSourceDirectory = "~/Fake";
297 Assert.AreEqual("~/Fake", ctrl.AppRelativeTemplateSourceDirectory, "AppRelativeTemplateSourceDirectory#2");
301 public void ApplyStyleSheetSkin ()
303 Page p = new Page ();
304 p.StyleSheetTheme = "";
305 Control c = new Control ();
306 c.ApplyStyleSheetSkin (p);
310 [Category ("NunitWeb")]
311 public void ApplyStyleSheetSkin_1 ()
313 WebTest.CopyResource (GetType (), "Theme2.skin", "App_Themes/Theme2/Theme2.skin");
314 WebTest t = new WebTest ();
315 PageDelegates pd = new PageDelegates ();
316 pd.PreInit = ApplyStyleSheetSkin_PreInit;
317 pd.Load = ApplyStyleSheetSkin_Load;
318 t.Invoker = new PageInvoker (pd);
319 string str = t.Run ();
321 public static void ApplyStyleSheetSkin_PreInit (Page p)
325 public static void ApplyStyleSheetSkin_Load (Page p)
327 Label lbl = new Label ();
330 lbl.Text = "StyleLabel";
331 p.Controls.Add (lbl);
332 lbl.ApplyStyleSheetSkin (p);
333 Assert.AreEqual (Color.Red, lbl.ForeColor, "ApplyStyleSheetSkin_BackColor");
334 Assert.AreEqual ("TextFromSkinFile", lbl.Text, "ApplyStyleSheetSkin");
338 [Category ("NunitWeb")]
339 public void ClearChildControlState ()
341 WebTest t = new WebTest (PageInvoker.CreateOnLoad (ClearChildControlState_Load));
343 FormRequest fr = new FormRequest (t.Response, "form1");
344 fr.Controls.Add ("__EVENTTARGET");
345 fr.Controls.Add ("__EVENTARGUMENT");
346 fr.Controls["__EVENTTARGET"].Value = "";
347 fr.Controls["__EVENTARGUMENT"].Value = "";
351 public static void ClearChildControlState_Load (Page p)
353 ControlWithState c1 = new ControlWithState ();
354 p.Form.Controls.Add (c1);
356 c1.ClearChildControlState ();
358 ControlWithState c2 = new ControlWithState ();
359 c1.Controls.Add (c2);
360 ControlWithState c3 = new ControlWithState ();
361 c2.Controls.Add (c3);
365 c3.State = "SubCool";
368 Assert.AreEqual ("State", c1.State, "ControlState#1");
369 Assert.AreEqual (null, c2.State, "ControlState#2");
370 Assert.AreEqual (null, c3.State, "ControlState#2");
375 [Category ("NunitWeb")]
376 public void ClearChildState ()
378 WebTest t = new WebTest (PageInvoker.CreateOnLoad (ClearChildState_Load));
380 FormRequest fr = new FormRequest (t.Response, "form1");
381 fr.Controls.Add ("__EVENTTARGET");
382 fr.Controls.Add ("__EVENTARGUMENT");
383 fr.Controls["__EVENTTARGET"].Value = "";
384 fr.Controls["__EVENTARGUMENT"].Value = "";
388 public static void ClearChildState_Load (Page p)
390 ControlWithState c1 = new ControlWithState ();
391 p.Form.Controls.Add (c1);
393 c1.ClearChildState ();
395 ControlWithState c2 = new ControlWithState ();
396 c1.Controls.Add (c2);
397 ControlWithState c3 = new ControlWithState ();
398 c2.Controls.Add (c3);
402 c2.Viewstate = "Very Cool";
403 c3.State = "SubCool";
404 c3.Viewstate = "Super Cool";
407 Assert.AreEqual ("State", c1.State, "ClearChildState#1");
408 Assert.AreEqual (null, c2.State, "ClearChildState#2");
409 Assert.AreEqual (null, c3.State, "ClearChildState#3");
410 Assert.AreEqual (null, c2.Viewstate, "ClearChildState#4");
411 Assert.AreEqual (null, c3.Viewstate, "ClearChildState#5");
416 public void DataBind ()
418 MyNC ctrl = new MyNC ();
419 ctrl.DataBinding += new EventHandler (ctrl_DataBinding);
420 Assert.AreEqual (false, _eventDataBinding, "Before DataBinding");
421 ctrl.DataBind (false);
422 Assert.AreEqual (false, _eventDataBinding, "Before DataBinding");
423 ctrl.DataBind (true);
424 Assert.AreEqual (true, _eventDataBinding, "After DataBinding");
426 bool _eventDataBinding;
427 void ctrl_DataBinding (object sender, EventArgs e)
429 _eventDataBinding = true;
433 public void DataBindChildren ()
435 MyNC ctrl1 = new MyNC ();
436 Control ctrl2 = new Control ();
437 Control ctrl3 = new Control ();
438 ctrl2.DataBinding += new EventHandler (ctrl2_DataBinding);
439 ctrl3.DataBinding += new EventHandler (ctrl3_DataBinding);
441 ctrl2.Controls.Add (ctrl3);
442 ctrl1.Controls.Add (ctrl2);
443 Assert.AreEqual (false, _eventChild1, "Before DataBinding#1");
444 Assert.AreEqual (false, _eventChild2, "Before DataBinding#2");
445 ctrl1.DataBindChildren ();
446 Assert.AreEqual (true, _eventChild1, "After DataBinding#1");
447 Assert.AreEqual (true, _eventChild2, "After DataBinding#2");
451 void ctrl3_DataBinding (object sender, EventArgs e)
455 void ctrl2_DataBinding (object sender, EventArgs e)
461 public void EnsureID ()
463 MyNC ctrl = new MyNC ();
464 MyNC ctrl1 = new MyNC ();
465 ctrl.Controls.Add (ctrl1);
466 Page p = new Page ();
467 p.Controls.Add (ctrl);
469 if (String.IsNullOrEmpty (ctrl.ID))
470 Assert.Fail ("EnsureID#1");
472 if (String.IsNullOrEmpty (ctrl1.ID))
473 Assert.Fail ("EnsureID#2");
477 [Category("NotWorking")]
480 WebTest t = new WebTest (PageInvoker.CreateOnLoad (Focus_Load));
481 string html = t.Run ();
482 Assert.AreEqual (3, contain (html, "TestBox"), "Focus script not created");
485 public static void Focus_Load (Page p)
487 TextBox tbx = new TextBox ();
489 p.Controls.Add (tbx);
492 int contain (string orig, string compare)
494 if (orig.IndexOf (compare) == -1)
496 return 1 + contain (orig.Substring (orig.IndexOf (compare) + compare.Length), compare);
500 public void HasEvent ()
502 MyNC ctrl1 = new MyNC ();
503 Assert.AreEqual (false, ctrl1.HasEvents (), "HasEvent#1");
504 EventHandler ctrl_hdlr = new EventHandler (ctrl1_Init);
505 ctrl1.Init += new EventHandler (ctrl1_Init);
506 ctrl1.Init += ctrl_hdlr;
507 Assert.AreEqual (true, ctrl1.HasEvents (), "HasEvent#2");
508 // Dosn't work than removed handler
509 //ctrl1.Init -= ctrl_hdlr;
510 //Assert.AreEqual (false, ctrl1.HasEvents (), "HasEvent#3");
512 void ctrl1_Init (object sender, EventArgs e)
514 throw new Exception ("The method or operation is not implemented.");
518 public void IsViewStateEnabled ()
520 DerivedControl c = new DerivedControl ();
521 Assert.IsTrue (c.DoIsViewStateEnabled);
522 Page p = new Page ();
525 Assert.IsTrue (c.DoIsViewStateEnabled);
526 p.EnableViewState = false;
527 Assert.IsFalse (c.DoIsViewStateEnabled);
531 [Category ("NunitWeb")]
532 public void ControlState ()
534 WebTest t = new WebTest (PageInvoker.CreateOnLoad (ControlState_Load));
536 FormRequest fr = new FormRequest (t.Response, "form1");
537 fr.Controls.Add ("__EVENTTARGET");
538 fr.Controls.Add ("__EVENTARGUMENT");
539 fr.Controls["__EVENTTARGET"].Value = "";
540 fr.Controls["__EVENTARGUMENT"].Value = "";
544 public static void ControlState_Load (Page p)
546 ControlWithState c1 = new ControlWithState ();
547 ControlWithState c2 = new ControlWithState ();
548 c1.Controls.Add (c2);
549 p.Form.Controls.Add (c1);
555 ControlWithState c3 = new ControlWithState ();
556 p.Form.Controls.Add (c3);
557 Assert.AreEqual ("State", c1.State, "ControlState");
558 Assert.AreEqual ("Cool", c2.State, "ControlState");
563 [Category ("NunitWeb")]
564 public void ControlState2 () {
565 WebTest t = new WebTest (PageInvoker.CreateOnLoad (ControlState2_Load));
567 FormRequest fr = new FormRequest (t.Response, "form1");
568 fr.Controls.Add ("__EVENTTARGET");
569 fr.Controls.Add ("__EVENTARGUMENT");
570 fr.Controls ["__EVENTTARGET"].Value = "";
571 fr.Controls ["__EVENTARGUMENT"].Value = "";
575 fr = new FormRequest (t.Response, "form1");
576 fr.Controls.Add ("__EVENTTARGET");
577 fr.Controls.Add ("__EVENTARGUMENT");
578 fr.Controls ["__EVENTTARGET"].Value = "";
579 fr.Controls ["__EVENTARGUMENT"].Value = "";
583 public static void ControlState2_Load (Page p) {
584 ControlWithState parent = new ControlWithState ();
585 p.Form.Controls.Add (parent);
588 parent.Controls.Clear ();
589 parent.ClearChildControlState ();
590 ControlWithState c1 = new ControlWithState ();
591 ControlWithState c2 = new ControlWithState ();
592 parent.Controls.Add (c1);
593 parent.Controls.Add (c2);
594 c1.State = "State1_1";
595 c2.State = "State1_2";
596 parent.State = "First";
598 else if (parent.State == "First") {
600 parent.Controls.Clear ();
601 parent.ClearChildControlState ();
602 ControlWithState c1 = new ControlWithState ();
603 ControlWithState c2 = new ControlWithState ();
604 parent.Controls.Add (c1);
605 parent.Controls.Add (c2);
606 c1.State = "State2_1";
607 c2.State = "State2_2";
608 parent.State = "Second";
611 // emulate CrerateChildControl only
612 parent.Controls.Clear ();
613 ControlWithState c1 = new ControlWithState ();
614 ControlWithState c2 = new ControlWithState ();
615 parent.Controls.Add (c1);
616 parent.Controls.Add (c2);
618 Assert.AreEqual ("State2_1", c1.State, "ControlState#1");
619 Assert.AreEqual ("State2_2", c2.State, "ControlState#2");
624 public void ClientIDSeparator ()
626 DerivedControl ctrl = new DerivedControl ();
627 Assert.AreEqual (95, (int) ctrl.ClientIDSeparator, "ClientIDSeparator");
631 public void IDSeparator ()
633 DerivedControl ctrl = new DerivedControl ();
634 Assert.AreEqual (36, (int) ctrl.IdSeparator, "IDSeparator");
638 [Category ("NunitWeb")]
639 public void IsChildControlStateCleared ()
641 WebTest t = new WebTest (PageInvoker.CreateOnLoad (IsChildControlStateCleared_Load));
643 FormRequest fr = new FormRequest (t.Response, "form1");
644 fr.Controls.Add ("__EVENTTARGET");
645 fr.Controls.Add ("__EVENTARGUMENT");
646 fr.Controls["__EVENTTARGET"].Value = "";
647 fr.Controls["__EVENTARGUMENT"].Value = "";
651 public static void IsChildControlStateCleared_Load (Page p)
653 ControlWithState c1 = new ControlWithState ();
654 p.Form.Controls.Add (c1);
656 Assert.IsFalse (c1.IsChildControlStateCleared, "ControlState#1");
657 c1.ClearChildControlState ();
658 Assert.IsTrue (c1.IsChildControlStateCleared, "ControlState#1");
660 ControlWithState c2 = new ControlWithState ();
661 c1.Controls.Add (c2);
662 ControlWithState c3 = new ControlWithState ();
663 c2.Controls.Add (c3);
665 Assert.IsFalse (c2.IsChildControlStateCleared, "ControlState#1");
666 Assert.IsFalse (c3.IsChildControlStateCleared, "ControlState#1");
671 c3.State = "SubCool";
676 [Category ("NunitWeb")]
677 public void LoadViewStateByID ()
679 ControlWithState c1 = new ControlWithState ();
680 ControlWithState c2 = new ControlWithState ();
681 c1.Controls.Add (c2);
682 Assert.AreEqual (false, c1.LoadViewStateByID, "LoadViewStateByID#1");
686 [Category ("NunitWeb")]
687 public void OpenFile ()
689 WebTest t = new WebTest (PageInvoker.CreateOnLoad (OpenFile_Load));
692 public static void OpenFile_Load (Page p)
694 DerivedControl ctrl = new DerivedControl ();
695 Stream strem = ctrl.OpenFile ("~/MyPage.aspx");
696 Assert.IsNotNull (strem, "OpenFile failed");
700 [Category ("NunitWeb")]
701 [ExpectedException (typeof (FileNotFoundException))]
702 public void OpenFile_Exception ()
704 WebTest t = new WebTest (PageInvoker.CreateOnLoad (OpenFileException_Load));
707 public static void OpenFileException_Load (Page p)
709 DerivedControl ctrl = new DerivedControl ();
710 Stream strem = ctrl.OpenFile ("~/Fake.tmp");
714 [Category ("NunitWeb")]
715 public void ResolveClientUrl ()
717 WebTest t = new WebTest (PageInvoker.CreateOnLoad (ResolveClientUrl_Load));
718 string html = t.Run ();
720 public static void ResolveClientUrl_Load (Page p)
722 Control ctrl = new Control ();
723 p.Controls.Add (ctrl);
724 string url = ctrl.ResolveClientUrl ("~/MyPage.aspx");
725 Assert.AreEqual ("MyPage.aspx", url, "ResolveClientUrl Failed");
727 Assert.AreEqual ("", ctrl.ResolveClientUrl (""), "empty string");
729 Assert.AreEqual ("./", ctrl.ResolveClientUrl ("~"), "~");
730 Assert.AreEqual ("./", ctrl.ResolveClientUrl ("~/"), "~/");
732 Assert.AreEqual ("../MyPage.aspx", ctrl.ResolveClientUrl ("~/../MyPage.aspx"), "~/../MyPage.aspx");
733 Assert.AreEqual ("../MyPage.aspx", ctrl.ResolveClientUrl ("~\\..\\MyPage.aspx"), "~\\..\\MyPage.aspx");
734 Assert.AreEqual ("MyPage.aspx", ctrl.ResolveClientUrl ("~////MyPage.aspx"), "ResolveClientUrl Failed");
735 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveClientUrl ("/MyPage.aspx"), "ResolveClientUrl Failed");
736 Assert.AreEqual ("/folder/MyPage.aspx", ctrl.ResolveClientUrl ("/folder/MyPage.aspx"), "ResolveClientUrl Failed");
737 Assert.AreEqual ("/NunitWeb/MyPage.aspx", ctrl.ResolveClientUrl ("/NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
738 Assert.AreEqual ("\\NunitWeb/MyPage.aspx", ctrl.ResolveClientUrl ("\\NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
739 Assert.AreEqual ("///NunitWeb\\..\\MyPage.aspx", ctrl.ResolveClientUrl ("///NunitWeb\\..\\MyPage.aspx"), "ResolveClientUrl Failed");
740 Assert.AreEqual ("NunitWeb/MyPage.aspx", ctrl.ResolveClientUrl ("NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
741 Assert.AreEqual ("NunitWeb/../MyPage.aspx", ctrl.ResolveClientUrl ("NunitWeb/../MyPage.aspx"), "ResolveClientUrl Failed");
742 Assert.AreEqual ("NunitWeb/./MyPage.aspx", ctrl.ResolveClientUrl ("NunitWeb/./MyPage.aspx"), "ResolveClientUrl Failed");
743 Assert.AreEqual ("http://google.com/", ctrl.ResolveClientUrl ("http://google.com/"), "ResolveClientUrl Failed");
745 Assert.AreEqual ("MyPage.aspx?param=val&yes=no", ctrl.ResolveClientUrl ("~/MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
746 Assert.AreEqual ("../MyPage.aspx?param=val&yes=no", ctrl.ResolveClientUrl ("~/../MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
748 Assert.AreEqual ("./MyPage.aspx", ctrl.ResolveClientUrl ("./MyPage.aspx"), "ResolveClientUrl Failed");
749 Assert.AreEqual ("../MyPage.aspx", ctrl.ResolveClientUrl ("../MyPage.aspx"), "ResolveClientUrl Failed");
754 [Category ("NunitWeb")]
755 public void ResolveClientUrl2 ()
757 WebTest t = new WebTest ("ResolveUrl.aspx");
758 PageDelegates delegates = new PageDelegates ();
759 delegates.Load = ResolveClientUrl2_Load;
760 t.Invoker = new PageInvoker (delegates);
761 string html = t.Run ();
764 public static void ResolveClientUrl2_Load (Page p)
766 Control uc = p.FindControl ("WebUserControl1");
767 Control ctrl = uc.FindControl ("Label");
769 string url = ctrl.ResolveClientUrl ("~/MyPage.aspx");
770 Assert.AreEqual ("MyPage.aspx", url, "ResolveClientUrl Failed");
772 Assert.AreEqual ("", ctrl.ResolveClientUrl (""), "empty string");
774 Assert.AreEqual ("./", ctrl.ResolveClientUrl ("~"), "~");
775 Assert.AreEqual ("./", ctrl.ResolveClientUrl ("~/"), "~/");
777 Assert.AreEqual ("../MyPage.aspx", ctrl.ResolveClientUrl ("~/../MyPage.aspx"), "~/../MyPage.aspx");
778 Assert.AreEqual ("../MyPage.aspx", ctrl.ResolveClientUrl ("~\\..\\MyPage.aspx"), "~\\..\\MyPage.aspx");
779 Assert.AreEqual ("MyPage.aspx", ctrl.ResolveClientUrl ("~////MyPage.aspx"), "ResolveClientUrl Failed");
780 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveClientUrl ("/MyPage.aspx"), "ResolveClientUrl Failed");
781 Assert.AreEqual ("/folder/MyPage.aspx", ctrl.ResolveClientUrl ("/folder/MyPage.aspx"), "ResolveClientUrl Failed");
782 Assert.AreEqual ("/NunitWeb/MyPage.aspx", ctrl.ResolveClientUrl ("/NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
783 Assert.AreEqual ("\\NunitWeb/MyPage.aspx", ctrl.ResolveClientUrl ("\\NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
784 Assert.AreEqual ("///NunitWeb\\..\\MyPage.aspx", ctrl.ResolveClientUrl ("///NunitWeb\\..\\MyPage.aspx"), "ResolveClientUrl Failed");
785 Assert.AreEqual ("Folder/NunitWeb/MyPage.aspx", ctrl.ResolveClientUrl ("NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
786 Assert.AreEqual ("Folder/MyPage.aspx", ctrl.ResolveClientUrl ("NunitWeb/../MyPage.aspx"), "ResolveClientUrl Failed");
787 Assert.AreEqual ("Folder/NunitWeb/MyPage.aspx", ctrl.ResolveClientUrl ("NunitWeb/./MyPage.aspx"), "ResolveClientUrl Failed");
788 Assert.AreEqual ("http://google.com/", ctrl.ResolveClientUrl ("http://google.com/"), "ResolveClientUrl Failed");
790 Assert.AreEqual ("MyPage.aspx?param=val&yes=no", ctrl.ResolveClientUrl ("~/MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
791 Assert.AreEqual ("../MyPage.aspx?param=val&yes=no", ctrl.ResolveClientUrl ("~/../MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
793 Assert.AreEqual ("Folder/MyPage.aspx", ctrl.ResolveClientUrl ("./MyPage.aspx"), "ResolveClientUrl Failed");
794 Assert.AreEqual ("MyPage.aspx", ctrl.ResolveClientUrl ("../MyPage.aspx"), "ResolveClientUrl Failed");
799 [Category ("NunitWeb")]
800 public void ResolveUrl ()
802 WebTest t = new WebTest (PageInvoker.CreateOnLoad (ResolveUrl_Load));
803 string html = t.Run ();
806 public static void ResolveUrl_Load (Page p)
808 string appPath = "/NunitWeb";
809 Control ctrl = new Control ();
810 p.Controls.Add (ctrl);
811 Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("~/MyPage.aspx"), "ResolveClientUrl Failed");
813 Assert.AreEqual ("", ctrl.ResolveUrl (""), "empty string");
815 Assert.AreEqual (appPath + "/", ctrl.ResolveUrl ("~"), "~");
816 Assert.AreEqual (appPath + "/", ctrl.ResolveUrl ("~/"), "~/");
818 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("~/../MyPage.aspx"), "~/../MyPage.aspx");
819 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("~\\..\\MyPage.aspx"), "~\\..\\MyPage.aspx");
820 Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("~////MyPage.aspx"), "ResolveClientUrl Failed");
821 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("/MyPage.aspx"), "ResolveClientUrl Failed");
822 Assert.AreEqual ("/folder/MyPage.aspx", ctrl.ResolveUrl ("/folder/MyPage.aspx"), "ResolveClientUrl Failed");
823 Assert.AreEqual ("/NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("/NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
824 Assert.AreEqual ("\\NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("\\NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
825 Assert.AreEqual ("///NunitWeb\\..\\MyPage.aspx", ctrl.ResolveUrl ("///NunitWeb\\..\\MyPage.aspx"), "ResolveClientUrl Failed");
826 Assert.AreEqual (appPath + "/NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
827 Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("NunitWeb/../MyPage.aspx"), "ResolveClientUrl Failed");
828 Assert.AreEqual (appPath + "/NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("NunitWeb/./MyPage.aspx"), "ResolveClientUrl Failed");
829 Assert.AreEqual ("http://google.com/", ctrl.ResolveUrl ("http://google.com/"), "ResolveClientUrl Failed");
831 Assert.AreEqual (appPath + "/MyPage.aspx?param=val&yes=no", ctrl.ResolveUrl ("~/MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
832 Assert.AreEqual ("/MyPage.aspx?param=val&yes=no", ctrl.ResolveUrl ("~/../MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
834 Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("./MyPage.aspx"), "ResolveClientUrl Failed");
835 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("../MyPage.aspx"), "ResolveClientUrl Failed");
837 Assert.AreEqual ("/", ctrl.ResolveUrl (".."), "..");
838 Assert.AreEqual ("/", ctrl.ResolveUrl ("../"), "../");
842 [Category ("NunitWeb")]
843 public void ResolveUrl2 ()
845 WebTest t = new WebTest ("ResolveUrl.aspx");
846 PageDelegates delegates = new PageDelegates ();
847 delegates.Load = ResolveUrl2_Load;
848 t.Invoker = new PageInvoker (delegates);
849 string html = t.Run ();
852 public static void ResolveUrl2_Load (Page p)
854 string appPath = "/NunitWeb";
855 Control uc = p.FindControl ("WebUserControl1");
856 Control ctrl = uc.FindControl ("Label");
858 Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("~/MyPage.aspx"), "ResolveClientUrl Failed");
860 Assert.AreEqual ("", ctrl.ResolveUrl (""), "empty string");
862 Assert.AreEqual (appPath + "/", ctrl.ResolveUrl ("~"), "~");
863 Assert.AreEqual (appPath + "/", ctrl.ResolveUrl ("~/"), "~/");
865 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("~/../MyPage.aspx"), "~/../MyPage.aspx");
866 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("~\\..\\MyPage.aspx"), "~\\..\\MyPage.aspx");
867 Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("~////MyPage.aspx"), "ResolveClientUrl Failed");
868 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("/MyPage.aspx"), "ResolveClientUrl Failed");
869 Assert.AreEqual ("/folder/MyPage.aspx", ctrl.ResolveUrl ("/folder/MyPage.aspx"), "ResolveClientUrl Failed");
870 Assert.AreEqual ("/NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("/NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
871 Assert.AreEqual ("\\NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("\\NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
872 Assert.AreEqual ("///NunitWeb\\..\\MyPage.aspx", ctrl.ResolveUrl ("///NunitWeb\\..\\MyPage.aspx"), "ResolveClientUrl Failed");
873 Assert.AreEqual (appPath + "/Folder/NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
874 Assert.AreEqual (appPath + "/Folder/MyPage.aspx", ctrl.ResolveUrl ("NunitWeb/../MyPage.aspx"), "ResolveClientUrl Failed");
875 Assert.AreEqual (appPath + "/Folder/NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("NunitWeb/./MyPage.aspx"), "ResolveClientUrl Failed");
876 Assert.AreEqual ("http://google.com/", ctrl.ResolveUrl ("http://google.com/"), "ResolveClientUrl Failed");
878 Assert.AreEqual (appPath + "/MyPage.aspx?param=val&yes=no", ctrl.ResolveUrl ("~/MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
879 Assert.AreEqual ("/MyPage.aspx?param=val&yes=no", ctrl.ResolveUrl ("~/../MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
881 Assert.AreEqual (appPath + "/Folder/MyPage.aspx", ctrl.ResolveUrl ("./MyPage.aspx"), "ResolveClientUrl Failed");
882 Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("../MyPage.aspx"), "ResolveClientUrl Failed");
884 Assert.AreEqual (appPath + "/", ctrl.ResolveUrl (".."), "..");
885 Assert.AreEqual (appPath + "/", ctrl.ResolveUrl ("../"), "../");
886 Assert.AreEqual ("/", ctrl.ResolveUrl ("../.."), "../..");
887 Assert.AreEqual ("/", ctrl.ResolveUrl ("../../"), "../../");
888 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("../../MyPage.aspx"), "../../MyPage.aspx");
892 [Category ("NotWorking")] // Not implemented exception
893 public void ResolveAdapter_2 ()
895 DerivedControl ctrl = new DerivedControl ();
896 Assert.AreEqual (null, ctrl.ResolveAdapter (), "ResolveAdapter");
900 public void EnableTheming ()
902 DerivedControl ctrl = new DerivedControl ();
903 Assert.AreEqual (true, ctrl.EnableTheming, "EnableTheming#1");
904 ctrl.EnableTheming = false;
905 Assert.AreEqual (false, ctrl.EnableTheming, "EnableTheming#2");
909 public void BindingContainer ()
911 ControlWithTemplate c = new ControlWithTemplate ();
912 c.Template = new CompiledTemplateBuilder (new BuildTemplateMethod (BindingContainer_BuildTemplate));
914 // cause CreateChildControls called
915 c.FindControl ("stam");
918 static void BindingContainer_BuildTemplate (Control control)
920 Control child1 = new Control ();
921 control.Controls.Add (child1);
923 Assert.IsTrue (Object.ReferenceEquals (child1.NamingContainer, control), "NamingContainer #1");
924 Assert.IsTrue (Object.ReferenceEquals (child1.BindingContainer, control), "BindingContainer #1");
926 NamingContainer nc = new NamingContainer ();
927 Control child2 = new Control ();
928 nc.Controls.Add (child2);
929 control.Controls.Add (nc);
931 Assert.IsTrue (Object.ReferenceEquals (child2.NamingContainer, nc), "NamingContainer #2");
932 Assert.IsTrue (Object.ReferenceEquals (child2.BindingContainer, nc), "BindingContainer #2");
934 // DetailsViewPagerRow marked to be not BindingContainer
935 DetailsViewPagerRow row = new DetailsViewPagerRow (0, DataControlRowType.Pager, DataControlRowState.Normal);
936 TableCell cell = new TableCell ();
937 Control child3 = new Control ();
938 cell.Controls.Add (child3);
939 row.Cells.Add (cell);
940 control.Controls.Add (row);
942 Assert.IsTrue (Object.ReferenceEquals (child3.NamingContainer, row), "NamingContainer #3");
943 Assert.IsTrue (Object.ReferenceEquals (child3.BindingContainer, control), "BindingContainer #3");
946 public void Control_Adapter ()
948 MyNC ctr = new MyNC ();
949 Assert.AreEqual (null, ctr.Adapter (), "Adapter");
952 public void ChildControlsCreated () {
953 ChildControlsCreatedControl ctr = new ChildControlsCreatedControl ();
954 ctr.Controls.Add (new Control ());
955 //ctr.DoEnsureChildControls ();
957 Assert.AreEqual (1, ctr.Controls.Count, "ChildControlsCreated#1");
958 ctr.SetChildControlsCreated (false);
959 Assert.AreEqual (1, ctr.Controls.Count, "ChildControlsCreated#2");
962 [Test (Description="Bug #594238")]
963 public void OverridenControlsPropertyAndPostBack_Bug594238 ()
965 WebTest t = new WebTest ("OverridenControlsPropertyAndPostBack_Bug594238.aspx");
968 FormRequest fr = new FormRequest (t.Response, "form1");
969 fr.Controls.Add ("__EVENTTARGET");
970 fr.Controls.Add ("__EVENTARGUMENT");
971 fr.Controls ["__EVENTTARGET"].Value = "container$children$lb";
972 fr.Controls ["__EVENTARGUMENT"].Value = String.Empty;
974 string originalHtml = "<span id=\"container\"><a id=\"container_children_lb\" href=\"javascript:__doPostBack('container$children$lb','')\">Woot! I got clicked!</a></span><hr/>";
975 string pageHtml = t.Run ();
976 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
978 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
981 [TestFixtureTearDown]
982 public void Tear_down ()
988 public void TestFixtureSetUp ()
990 WebTest.CopyResource (GetType (), "ResolveUrl.aspx", "ResolveUrl.aspx");
991 WebTest.CopyResource (GetType (), "ResolveUrl.ascx", "Folder/ResolveUrl.ascx");
992 WebTest.CopyResource (GetType (), "OverridenControlsPropertyAndPostBack_Bug594238.aspx", "OverridenControlsPropertyAndPostBack_Bug594238.aspx");
996 public void GetRouteUrl_Object ()
998 var t = new WebTest (PageInvoker.CreateOnLoad (GetRouteUrl_Object_Load));
1002 public static void GetRouteUrl_Object_Load (Page p)
1004 RouteTable.Routes.Clear ();
1006 var ctl = new Control ();
1007 object obj = new { foo = "one", bar = "two" };
1008 string path = ctl.GetRouteUrl (obj);
1009 Assert.IsNull (path, "#A1");
1011 RouteTable.Routes.Add (new Route ("{foo}-{bar}", new PageRouteHandler ("~/default.aspx")));
1012 path = ctl.GetRouteUrl (obj);
1013 Assert.IsNotNull (path, "#A2-1");
1014 Assert.AreEqual ("/NunitWeb/one-two", path, "#A2-2");
1016 path = ctl.GetRouteUrl ((object)null);
1017 Assert.IsNull (path, "#A3");
1021 public void GetRouteUrl_RouteValueDictionary ()
1023 var t = new WebTest (PageInvoker.CreateOnLoad (GetRouteUrl_RouteValueDictionary_Load));
1027 public static void GetRouteUrl_RouteValueDictionary_Load (Page p)
1029 RouteTable.Routes.Clear ();
1031 var ctl = new Control ();
1032 var rvd = new RouteValueDictionary {
1036 string path = ctl.GetRouteUrl (rvd);
1037 Assert.IsNull (path, "#A1");
1039 RouteTable.Routes.Add (new Route ("{foo}-{bar}", new PageRouteHandler ("~/default.aspx")));
1040 path = ctl.GetRouteUrl (rvd);
1041 Assert.IsNotNull (path, "#A2-1");
1042 Assert.AreEqual ("/NunitWeb/one-two", path, "#A2-2");
1044 path = ctl.GetRouteUrl ((RouteValueDictionary) null);
1045 Assert.IsNull (path, "#A3");
1049 public void GetRouteUrl_String_Object ()
1051 var t = new WebTest (PageInvoker.CreateOnLoad (GetRouteUrl_String_Object_Load));
1055 public static void GetRouteUrl_String_Object_Load (Page p)
1057 RouteTable.Routes.Clear ();
1059 var ctl = new Control ();
1060 object obj = new { foo = "one", bar = "two" };
1062 AssertExtensions.Throws<ArgumentException> (() => {
1063 path = ctl.GetRouteUrl ("myroute1", obj);
1066 RouteTable.Routes.Add (new Route ("{foo}-{bar}", new PageRouteHandler ("~/default.aspx")));
1067 RouteTable.Routes.Add ("myroute1", new Route ("{bar}-{foo}", new PageRouteHandler ("~/default.aspx")));
1068 path = ctl.GetRouteUrl ("myroute1", obj);
1069 Assert.IsNotNull (path, "#A2-1");
1070 Assert.AreEqual ("/NunitWeb/two-one", path, "#A2-2");
1072 path = ctl.GetRouteUrl ("myroute1", (object) null);
1073 Assert.IsNull (path, "#A3");
1077 public void GetRouteUrl_String_RouteValueDictionary ()
1079 var t = new WebTest (PageInvoker.CreateOnLoad (GetRouteUrl_String_RouteValueDictionary_Load));
1083 public static void GetRouteUrl_String_RouteValueDictionary_Load (Page p)
1085 RouteTable.Routes.Clear ();
1087 var ctl = new Control ();
1088 var rvd = new RouteValueDictionary {
1093 AssertExtensions.Throws<ArgumentException> (() => {
1094 path = ctl.GetRouteUrl ("myroute", rvd);
1097 RouteTable.Routes.Add (new Route ("{foo}-{bar}", new PageRouteHandler ("~/default.aspx")));
1098 RouteTable.Routes.Add ("myroute", new Route ("{bar}-{foo}", new PageRouteHandler ("~/default.aspx")));
1099 path = ctl.GetRouteUrl ("myroute", rvd);
1100 Assert.IsNotNull (path, "#A2-1");
1101 Assert.AreEqual ("/NunitWeb/two-one", path, "#A2-2");
1103 path = ctl.GetRouteUrl ("myroute", (RouteValueDictionary) null);
1104 Assert.IsNull (path, "#A3-1");
1106 path = ctl.GetRouteUrl (null, (RouteValueDictionary) null);
1107 Assert.IsNull (path, "#A3-2");
1109 path = ctl.GetRouteUrl (String.Empty, (RouteValueDictionary) null);
1110 Assert.IsNull (path, "#A3-3");
1113 class ControlWithState : Control
1119 get { return _state; }
1120 set { _state = value; }
1123 public string Viewstate {
1124 get { return (string) ViewState ["Viewstate"]; }
1125 set { ViewState ["Viewstate"] = value; }
1128 protected internal override void OnInit (EventArgs e)
1131 Page.RegisterRequiresControlState (this);
1134 protected internal override object SaveControlState ()
1139 protected internal override void LoadControlState (object savedState)
1141 State = (string) savedState;
1144 public new void ClearChildState ()
1146 base.ClearChildState ();
1149 public new void ClearChildControlState ()
1151 base.ClearChildControlState ();
1154 public new bool IsChildControlStateCleared
1156 get { return base.IsChildControlStateCleared; }
1159 public new bool LoadViewStateByID
1161 get { return base.LoadViewStateByID; }
1165 class MyNC : Control, INamingContainer
1167 public ControlAdapter Adapter ()
1169 return base.Adapter;
1172 public new void DataBind (bool opt)
1174 base.DataBind (opt);
1177 public new void DataBindChildren ()
1179 base.DataBindChildren ();
1182 public new void EnsureID ()
1187 public new bool HasEvents ()
1189 return base.HasEvents ();
1193 class DerivedControl : Control
1195 ControlCollection coll;
1197 public DerivedControl ()
1199 coll = new ControlCollection (this);
1202 public override ControlCollection Controls
1204 get { return coll; }
1207 public bool DoIsViewStateEnabled
1209 get { return IsViewStateEnabled; }
1212 public new char ClientIDSeparator
1214 get { return base.ClientIDSeparator; }
1217 public new char IdSeparator
1219 get { return base.IdSeparator; }
1222 public new Stream OpenFile (string path)
1224 return base.OpenFile (path);
1227 public new ControlAdapter ResolveAdapter ()
1229 return base.ResolveAdapter ();
1233 class NamingContainer : Control, INamingContainer
1237 class ControlWithTemplate : Control
1239 ITemplate _template;
1241 [TemplateContainer (typeof (TemplateContainer))]
1242 public ITemplate Template
1244 get { return _template; }
1245 set { _template = value; }
1248 protected internal override void CreateChildControls ()
1252 TemplateContainer container = new TemplateContainer ();
1253 Controls.Add (container);
1255 if (Template != null)
1256 Template.InstantiateIn (container);
1260 class TemplateContainer : Control, INamingContainer
1266 public class Customadaptercontrol : Control
1268 public new ControlAdapter Adapter {
1269 get { return base.Adapter; }
1272 public new ControlAdapter ResolveAdapter ()
1274 return base.ResolveAdapter ();
1278 public class Customadapter : ControlAdapter
1282 class EnsureIDControl : Control {
1283 public void DoEnsureID () {
1288 public class ChildControlsCreatedControl : Control
1290 protected internal override void CreateChildControls () {
1291 Controls.Add (new Control ());
1294 public void DoEnsureChildControls () {
1295 EnsureChildControls ();
1298 public void SetChildControlsCreated (bool value) {
1299 ChildControlsCreated = value;