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;
48 using System.Web.Routing;
51 namespace MonoTests.System.Web.UI
54 public class ControlTest
57 public void DataBindingInterfaceTest ()
60 DataBindingCollection db;
63 Assert.AreEqual (false, ((IDataBindingsAccessor) c).HasDataBindings, "DB1");
64 db = ((IDataBindingsAccessor) c).DataBindings;
65 Assert.IsNotNull (db, "DB2");
66 Assert.AreEqual (false, ((IDataBindingsAccessor) c).HasDataBindings, "DB3");
67 db.Add (new DataBinding ("property", typeof (bool), "expression"));
68 Assert.AreEqual (true, ((IDataBindingsAccessor) c).HasDataBindings);
72 public void FindControl_NamingContainer ()
74 Control topControl = new NamingContainer ();
75 topControl.ID = "top";
77 Control controlLevel1A = new Control ();
78 controlLevel1A.ID = "Level1#A";
79 topControl.Controls.Add (controlLevel1A);
81 Control controlLevel1B = new Control ();
82 controlLevel1B.ID = "Level1#B";
83 topControl.Controls.Add (controlLevel1B);
85 Control controlLevel2AA = new Control ();
86 controlLevel2AA.ID = "Level2#AA";
87 controlLevel1A.Controls.Add (controlLevel2AA);
89 Control controlLevel2AB = new Control ();
90 controlLevel2AB.ID = "Level2#AB";
91 controlLevel1A.Controls.Add (controlLevel2AB);
93 Control foundControl = topControl.FindControl ("Level1#A");
94 Assert.IsNotNull (foundControl, "#A1");
95 Assert.AreSame (controlLevel1A, foundControl, "#A2");
97 foundControl = topControl.FindControl ("LEVEL1#B");
98 Assert.IsNotNull (foundControl, "#B1");
99 Assert.AreSame (controlLevel1B, foundControl, "#B2");
101 foundControl = topControl.FindControl ("LeVeL2#AB");
102 Assert.IsNotNull (foundControl, "#C1");
103 Assert.AreSame (controlLevel2AB, foundControl, "#C2");
105 foundControl = topControl.FindControl ("doesnotexist");
106 Assert.IsNull (foundControl, "#D1");
107 foundControl = topControl.FindControl ("top");
108 Assert.IsNull (foundControl, "#D2");
110 foundControl = controlLevel1A.FindControl ("Level2#AA");
111 Assert.IsNotNull (foundControl, "#E1");
112 Assert.AreSame (controlLevel2AA, foundControl, "#E2");
114 foundControl = controlLevel1A.FindControl ("LEveL2#ab");
115 Assert.IsNotNull (foundControl, "#F1");
116 Assert.AreSame (controlLevel2AB, foundControl, "#F2");
120 public void UniqueID1 ()
123 Control nc = new MyNC ();
124 Assert.IsNull (nc.UniqueID, "nulltest");
128 public void UniqueID1_1 () {
130 Control nc = new MyNC ();
131 Page p = new Page ();
133 Assert.IsNotNull (nc.UniqueID, "notnull");
137 public void UniqueID2 ()
140 Control nc = new MyNC ();
141 Control nc2 = new MyNC ();
142 nc2.Controls.Add (nc);
143 Assert.IsNotNull (nc.UniqueID, "notnull");
144 Assert.IsTrue (nc.UniqueID.IndexOfAny (new char[] { ':', '$' }) == -1, "separator");
148 public void UniqueID2_1 () {
150 Control nc = new MyNC ();
151 Control nc2 = new MyNC ();
152 nc2.Controls.Add (nc);
153 Page p = new Page ();
154 p.Controls.Add (nc2);
155 Assert.IsNotNull (nc.UniqueID, "notnull");
156 Assert.IsTrue (nc.UniqueID.IndexOfAny (new char [] { ':', '$' }) != -1, "separator");
160 public void UniqueID3 ()
163 Control control = new Control ();
164 Control nc = new MyNC ();
166 control.Controls.Add (nc);
167 Assert.IsNull (nc.UniqueID, "null");
171 public void UniqueID4 ()
174 Control control = new Control ();
175 Control nc = new MyNC ();
177 nc.Controls.Add (control);
178 Assert.IsNotNull (control.UniqueID, "notnull");
182 public void UniqueID5 ()
185 Control control = new Control ();
186 Control nc = new MyNC ();
187 Control nc2 = new MyNC ();
189 nc2.Controls.Add (nc);
190 nc.Controls.Add (control);
191 Assert.IsNotNull (control.UniqueID, "notnull");
192 Assert.IsNull (nc2.ID, "null-1");
193 Assert.IsNull (nc.ID, "null-2");
194 Assert.IsTrue (-1 != control.UniqueID.IndexOfAny (new char[] { ':', '$' }), "separator");
198 public void UniqueID6 () {
200 Control nc = new MyNC ();
201 Page p = new Page ();
203 Assert.IsNotNull (nc.UniqueID, "notnull");
205 Control c1 = new Control ();
206 Control c2 = new Control ();
207 nc.Controls.Add (c1);
208 nc.Controls.Add (c2);
209 string uid1_1 = c1.UniqueID;
210 string uid2_1 = c2.UniqueID;
212 nc.Controls.Clear ();
214 Assert.IsNull (c1.UniqueID);
215 Assert.IsNull (c2.UniqueID);
217 // ad in another order
218 nc.Controls.Add (c2);
219 nc.Controls.Add (c1);
220 string uid1_2 = c1.UniqueID;
221 string uid2_2 = c2.UniqueID;
223 Assert.IsFalse (uid1_1 == uid1_2);
224 Assert.IsFalse (uid2_1 == uid2_2);
225 Assert.AreEqual (uid1_1, uid2_2);
226 Assert.AreEqual (uid2_1, uid1_2);
228 nc.Controls.Remove (c1);
229 nc.Controls.Add (c1);
230 string uid1_3 = c1.UniqueID;
231 Assert.IsFalse (uid1_3 == uid1_2, "id was not reset");
233 EnsureIDControl c3 = new EnsureIDControl ();
234 nc.Controls.Add (c3);
235 string uid3_1 = c3.UniqueID;
237 Assert.IsNotNull (c3.ID);
238 nc.Controls.Remove (c3);
239 nc.Controls.Add (c3);
240 string uid3_2 = c3.UniqueID;
241 Assert.IsNull (c3.ID);
242 Assert.IsFalse (uid3_1 == uid3_2, "id was not reset");
246 public void ClientID ()
249 Control control = new Control ();
250 Control nc = new MyNC ();
251 Control nc2 = new MyNC ();
252 Control nc3 = new MyNC ();
254 nc3.Controls.Add (nc2);
255 nc2.Controls.Add (nc);
256 nc.Controls.Add (control);
257 string expected = "ctl00_ctl00_ctl00";
258 Assert.AreEqual (expected, control.ClientID, "ClientID");
261 // From bug #76919: Control uses _controls instead of
262 // Controls when RenderChildren is called.
264 public void Controls1 ()
266 DerivedControl derived = new DerivedControl ();
267 derived.Controls.Add (new LiteralControl ("hola"));
268 StringWriter sw = new StringWriter ();
269 HtmlTextWriter htw = new HtmlTextWriter (sw);
270 derived.RenderControl (htw);
271 string result = sw.ToString ();
272 Assert.AreEqual ("", result, "#01");
275 [Test] // Bug #471305
276 [Category ("NunitWeb")]
277 public void NoDoubleOnInitOnRemoveAdd ()
279 WebTest.CopyResource (GetType (), "NoDoubleOnInitOnRemoveAdd.aspx", "NoDoubleOnInitOnRemoveAdd.aspx");
280 WebTest.CopyResource (GetType (), "NoDoubleOnInitOnRemoveAdd.aspx.cs", "NoDoubleOnInitOnRemoveAdd.aspx.cs");
281 WebTest t = new WebTest ("NoDoubleOnInitOnRemoveAdd.aspx");
282 string html = t.Run ();
284 Assert.AreEqual (-1, html.IndexOf ("<span>label</span><span>label</span>"), "#A1");
288 [Category("NunitWeb")]
289 public void AppRelativeTemplateSourceDirectory ()
291 new WebTest(PageInvoker.CreateOnLoad(AppRelativeTemplateSourceDirectory_Load)).Run();
294 public static void AppRelativeTemplateSourceDirectory_Load(Page p)
296 Control ctrl = new Control();
297 Assert.AreEqual("~/", ctrl.AppRelativeTemplateSourceDirectory, "AppRelativeTemplateSourceDirectory#1");
298 ctrl.AppRelativeTemplateSourceDirectory = "~/Fake";
299 Assert.AreEqual("~/Fake", ctrl.AppRelativeTemplateSourceDirectory, "AppRelativeTemplateSourceDirectory#2");
303 public void ApplyStyleSheetSkin ()
305 Page p = new Page ();
306 p.StyleSheetTheme = "";
307 Control c = new Control ();
308 c.ApplyStyleSheetSkin (p);
312 [Category ("NunitWeb")]
313 public void ApplyStyleSheetSkin_1 ()
315 WebTest.CopyResource (GetType (), "Theme2.skin", "App_Themes/Theme2/Theme2.skin");
316 WebTest t = new WebTest ();
317 PageDelegates pd = new PageDelegates ();
318 pd.PreInit = ApplyStyleSheetSkin_PreInit;
319 pd.Load = ApplyStyleSheetSkin_Load;
320 t.Invoker = new PageInvoker (pd);
321 string str = t.Run ();
323 public static void ApplyStyleSheetSkin_PreInit (Page p)
327 public static void ApplyStyleSheetSkin_Load (Page p)
329 Label lbl = new Label ();
332 lbl.Text = "StyleLabel";
333 p.Controls.Add (lbl);
334 lbl.ApplyStyleSheetSkin (p);
335 Assert.AreEqual (Color.Red, lbl.ForeColor, "ApplyStyleSheetSkin_BackColor");
336 Assert.AreEqual ("TextFromSkinFile", lbl.Text, "ApplyStyleSheetSkin");
340 [Category ("NunitWeb")]
341 public void ClearChildControlState ()
343 WebTest t = new WebTest (PageInvoker.CreateOnLoad (ClearChildControlState_Load));
345 FormRequest fr = new FormRequest (t.Response, "form1");
346 fr.Controls.Add ("__EVENTTARGET");
347 fr.Controls.Add ("__EVENTARGUMENT");
348 fr.Controls["__EVENTTARGET"].Value = "";
349 fr.Controls["__EVENTARGUMENT"].Value = "";
353 public static void ClearChildControlState_Load (Page p)
355 ControlWithState c1 = new ControlWithState ();
356 p.Form.Controls.Add (c1);
358 c1.ClearChildControlState ();
360 ControlWithState c2 = new ControlWithState ();
361 c1.Controls.Add (c2);
362 ControlWithState c3 = new ControlWithState ();
363 c2.Controls.Add (c3);
367 c3.State = "SubCool";
370 Assert.AreEqual ("State", c1.State, "ControlState#1");
371 Assert.AreEqual (null, c2.State, "ControlState#2");
372 Assert.AreEqual (null, c3.State, "ControlState#2");
377 [Category ("NunitWeb")]
378 public void ClearChildState ()
380 WebTest t = new WebTest (PageInvoker.CreateOnLoad (ClearChildState_Load));
382 FormRequest fr = new FormRequest (t.Response, "form1");
383 fr.Controls.Add ("__EVENTTARGET");
384 fr.Controls.Add ("__EVENTARGUMENT");
385 fr.Controls["__EVENTTARGET"].Value = "";
386 fr.Controls["__EVENTARGUMENT"].Value = "";
390 public static void ClearChildState_Load (Page p)
392 ControlWithState c1 = new ControlWithState ();
393 p.Form.Controls.Add (c1);
395 c1.ClearChildState ();
397 ControlWithState c2 = new ControlWithState ();
398 c1.Controls.Add (c2);
399 ControlWithState c3 = new ControlWithState ();
400 c2.Controls.Add (c3);
404 c2.Viewstate = "Very Cool";
405 c3.State = "SubCool";
406 c3.Viewstate = "Super Cool";
409 Assert.AreEqual ("State", c1.State, "ClearChildState#1");
410 Assert.AreEqual (null, c2.State, "ClearChildState#2");
411 Assert.AreEqual (null, c3.State, "ClearChildState#3");
412 Assert.AreEqual (null, c2.Viewstate, "ClearChildState#4");
413 Assert.AreEqual (null, c3.Viewstate, "ClearChildState#5");
418 public void DataBind ()
420 MyNC ctrl = new MyNC ();
421 ctrl.DataBinding += new EventHandler (ctrl_DataBinding);
422 Assert.AreEqual (false, _eventDataBinding, "Before DataBinding");
423 ctrl.DataBind (false);
424 Assert.AreEqual (false, _eventDataBinding, "Before DataBinding");
425 ctrl.DataBind (true);
426 Assert.AreEqual (true, _eventDataBinding, "After DataBinding");
428 bool _eventDataBinding;
429 void ctrl_DataBinding (object sender, EventArgs e)
431 _eventDataBinding = true;
435 public void DataBindChildren ()
437 MyNC ctrl1 = new MyNC ();
438 Control ctrl2 = new Control ();
439 Control ctrl3 = new Control ();
440 ctrl2.DataBinding += new EventHandler (ctrl2_DataBinding);
441 ctrl3.DataBinding += new EventHandler (ctrl3_DataBinding);
443 ctrl2.Controls.Add (ctrl3);
444 ctrl1.Controls.Add (ctrl2);
445 Assert.AreEqual (false, _eventChild1, "Before DataBinding#1");
446 Assert.AreEqual (false, _eventChild2, "Before DataBinding#2");
447 ctrl1.DataBindChildren ();
448 Assert.AreEqual (true, _eventChild1, "After DataBinding#1");
449 Assert.AreEqual (true, _eventChild2, "After DataBinding#2");
453 void ctrl3_DataBinding (object sender, EventArgs e)
457 void ctrl2_DataBinding (object sender, EventArgs e)
463 public void EnsureID ()
465 MyNC ctrl = new MyNC ();
466 MyNC ctrl1 = new MyNC ();
467 ctrl.Controls.Add (ctrl1);
468 Page p = new Page ();
469 p.Controls.Add (ctrl);
471 if (String.IsNullOrEmpty (ctrl.ID))
472 Assert.Fail ("EnsureID#1");
474 if (String.IsNullOrEmpty (ctrl1.ID))
475 Assert.Fail ("EnsureID#2");
479 [Category("NotWorking")]
482 WebTest t = new WebTest (PageInvoker.CreateOnLoad (Focus_Load));
483 string html = t.Run ();
484 Assert.AreEqual (3, contain (html, "TestBox"), "Focus script not created");
487 public static void Focus_Load (Page p)
489 TextBox tbx = new TextBox ();
491 p.Controls.Add (tbx);
494 int contain (string orig, string compare)
496 if (orig.IndexOf (compare) == -1)
498 return 1 + contain (orig.Substring (orig.IndexOf (compare) + compare.Length), compare);
502 public void HasEvent ()
504 MyNC ctrl1 = new MyNC ();
505 Assert.AreEqual (false, ctrl1.HasEvents (), "HasEvent#1");
506 EventHandler ctrl_hdlr = new EventHandler (ctrl1_Init);
507 ctrl1.Init += new EventHandler (ctrl1_Init);
508 ctrl1.Init += ctrl_hdlr;
509 Assert.AreEqual (true, ctrl1.HasEvents (), "HasEvent#2");
510 // Dosn't work than removed handler
511 //ctrl1.Init -= ctrl_hdlr;
512 //Assert.AreEqual (false, ctrl1.HasEvents (), "HasEvent#3");
514 void ctrl1_Init (object sender, EventArgs e)
516 throw new Exception ("The method or operation is not implemented.");
520 public void IsViewStateEnabled ()
522 DerivedControl c = new DerivedControl ();
523 Assert.IsTrue (c.DoIsViewStateEnabled);
524 Page p = new Page ();
527 Assert.IsTrue (c.DoIsViewStateEnabled);
528 p.EnableViewState = false;
529 Assert.IsFalse (c.DoIsViewStateEnabled);
533 [Category ("NunitWeb")]
534 public void ControlState ()
536 WebTest t = new WebTest (PageInvoker.CreateOnLoad (ControlState_Load));
538 FormRequest fr = new FormRequest (t.Response, "form1");
539 fr.Controls.Add ("__EVENTTARGET");
540 fr.Controls.Add ("__EVENTARGUMENT");
541 fr.Controls["__EVENTTARGET"].Value = "";
542 fr.Controls["__EVENTARGUMENT"].Value = "";
546 public static void ControlState_Load (Page p)
548 ControlWithState c1 = new ControlWithState ();
549 ControlWithState c2 = new ControlWithState ();
550 c1.Controls.Add (c2);
551 p.Form.Controls.Add (c1);
557 ControlWithState c3 = new ControlWithState ();
558 p.Form.Controls.Add (c3);
559 Assert.AreEqual ("State", c1.State, "ControlState");
560 Assert.AreEqual ("Cool", c2.State, "ControlState");
565 [Category ("NunitWeb")]
566 public void ControlState2 () {
567 WebTest t = new WebTest (PageInvoker.CreateOnLoad (ControlState2_Load));
569 FormRequest fr = new FormRequest (t.Response, "form1");
570 fr.Controls.Add ("__EVENTTARGET");
571 fr.Controls.Add ("__EVENTARGUMENT");
572 fr.Controls ["__EVENTTARGET"].Value = "";
573 fr.Controls ["__EVENTARGUMENT"].Value = "";
577 fr = new FormRequest (t.Response, "form1");
578 fr.Controls.Add ("__EVENTTARGET");
579 fr.Controls.Add ("__EVENTARGUMENT");
580 fr.Controls ["__EVENTTARGET"].Value = "";
581 fr.Controls ["__EVENTARGUMENT"].Value = "";
585 public static void ControlState2_Load (Page p) {
586 ControlWithState parent = new ControlWithState ();
587 p.Form.Controls.Add (parent);
590 parent.Controls.Clear ();
591 parent.ClearChildControlState ();
592 ControlWithState c1 = new ControlWithState ();
593 ControlWithState c2 = new ControlWithState ();
594 parent.Controls.Add (c1);
595 parent.Controls.Add (c2);
596 c1.State = "State1_1";
597 c2.State = "State1_2";
598 parent.State = "First";
600 else if (parent.State == "First") {
602 parent.Controls.Clear ();
603 parent.ClearChildControlState ();
604 ControlWithState c1 = new ControlWithState ();
605 ControlWithState c2 = new ControlWithState ();
606 parent.Controls.Add (c1);
607 parent.Controls.Add (c2);
608 c1.State = "State2_1";
609 c2.State = "State2_2";
610 parent.State = "Second";
613 // emulate CrerateChildControl only
614 parent.Controls.Clear ();
615 ControlWithState c1 = new ControlWithState ();
616 ControlWithState c2 = new ControlWithState ();
617 parent.Controls.Add (c1);
618 parent.Controls.Add (c2);
620 Assert.AreEqual ("State2_1", c1.State, "ControlState#1");
621 Assert.AreEqual ("State2_2", c2.State, "ControlState#2");
626 public void ClientIDSeparator ()
628 DerivedControl ctrl = new DerivedControl ();
629 Assert.AreEqual (95, (int) ctrl.ClientIDSeparator, "ClientIDSeparator");
633 public void IDSeparator ()
635 DerivedControl ctrl = new DerivedControl ();
636 Assert.AreEqual (36, (int) ctrl.IdSeparator, "IDSeparator");
640 [Category ("NunitWeb")]
641 public void IsChildControlStateCleared ()
643 WebTest t = new WebTest (PageInvoker.CreateOnLoad (IsChildControlStateCleared_Load));
645 FormRequest fr = new FormRequest (t.Response, "form1");
646 fr.Controls.Add ("__EVENTTARGET");
647 fr.Controls.Add ("__EVENTARGUMENT");
648 fr.Controls["__EVENTTARGET"].Value = "";
649 fr.Controls["__EVENTARGUMENT"].Value = "";
653 public static void IsChildControlStateCleared_Load (Page p)
655 ControlWithState c1 = new ControlWithState ();
656 p.Form.Controls.Add (c1);
658 Assert.IsFalse (c1.IsChildControlStateCleared, "ControlState#1");
659 c1.ClearChildControlState ();
660 Assert.IsTrue (c1.IsChildControlStateCleared, "ControlState#1");
662 ControlWithState c2 = new ControlWithState ();
663 c1.Controls.Add (c2);
664 ControlWithState c3 = new ControlWithState ();
665 c2.Controls.Add (c3);
667 Assert.IsFalse (c2.IsChildControlStateCleared, "ControlState#1");
668 Assert.IsFalse (c3.IsChildControlStateCleared, "ControlState#1");
673 c3.State = "SubCool";
678 [Category ("NunitWeb")]
679 public void LoadViewStateByID ()
681 ControlWithState c1 = new ControlWithState ();
682 ControlWithState c2 = new ControlWithState ();
683 c1.Controls.Add (c2);
684 Assert.AreEqual (false, c1.LoadViewStateByID, "LoadViewStateByID#1");
688 [Category ("NunitWeb")]
689 public void OpenFile ()
691 WebTest t = new WebTest (PageInvoker.CreateOnLoad (OpenFile_Load));
694 public static void OpenFile_Load (Page p)
696 DerivedControl ctrl = new DerivedControl ();
697 Stream strem = ctrl.OpenFile ("~/MyPage.aspx");
698 Assert.IsNotNull (strem, "OpenFile failed");
702 [Category ("NunitWeb")]
703 [ExpectedException (typeof (FileNotFoundException))]
704 public void OpenFile_Exception ()
706 WebTest t = new WebTest (PageInvoker.CreateOnLoad (OpenFileException_Load));
709 public static void OpenFileException_Load (Page p)
711 DerivedControl ctrl = new DerivedControl ();
712 Stream strem = ctrl.OpenFile ("~/Fake.tmp");
716 [Category ("NunitWeb")]
717 public void ResolveClientUrl ()
719 WebTest t = new WebTest (PageInvoker.CreateOnLoad (ResolveClientUrl_Load));
720 string html = t.Run ();
722 public static void ResolveClientUrl_Load (Page p)
724 Control ctrl = new Control ();
725 p.Controls.Add (ctrl);
726 string url = ctrl.ResolveClientUrl ("~/MyPage.aspx");
727 Assert.AreEqual ("MyPage.aspx", url, "ResolveClientUrl Failed");
729 Assert.AreEqual ("", ctrl.ResolveClientUrl (""), "empty string");
731 Assert.AreEqual ("./", ctrl.ResolveClientUrl ("~"), "~");
732 Assert.AreEqual ("./", ctrl.ResolveClientUrl ("~/"), "~/");
734 Assert.AreEqual ("../MyPage.aspx", ctrl.ResolveClientUrl ("~/../MyPage.aspx"), "~/../MyPage.aspx");
735 Assert.AreEqual ("../MyPage.aspx", ctrl.ResolveClientUrl ("~\\..\\MyPage.aspx"), "~\\..\\MyPage.aspx");
736 Assert.AreEqual ("MyPage.aspx", ctrl.ResolveClientUrl ("~////MyPage.aspx"), "ResolveClientUrl Failed");
737 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveClientUrl ("/MyPage.aspx"), "ResolveClientUrl Failed");
738 Assert.AreEqual ("/folder/MyPage.aspx", ctrl.ResolveClientUrl ("/folder/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 ("NunitWeb/../MyPage.aspx", ctrl.ResolveClientUrl ("NunitWeb/../MyPage.aspx"), "ResolveClientUrl Failed");
744 Assert.AreEqual ("NunitWeb/./MyPage.aspx", ctrl.ResolveClientUrl ("NunitWeb/./MyPage.aspx"), "ResolveClientUrl Failed");
745 Assert.AreEqual ("http://google.com/", ctrl.ResolveClientUrl ("http://google.com/"), "ResolveClientUrl Failed");
747 Assert.AreEqual ("MyPage.aspx?param=val&yes=no", ctrl.ResolveClientUrl ("~/MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
748 Assert.AreEqual ("../MyPage.aspx?param=val&yes=no", ctrl.ResolveClientUrl ("~/../MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
750 Assert.AreEqual ("./MyPage.aspx", ctrl.ResolveClientUrl ("./MyPage.aspx"), "ResolveClientUrl Failed");
751 Assert.AreEqual ("../MyPage.aspx", ctrl.ResolveClientUrl ("../MyPage.aspx"), "ResolveClientUrl Failed");
756 [Category ("NunitWeb")]
757 public void ResolveClientUrl2 ()
759 WebTest t = new WebTest ("ResolveUrl.aspx");
760 PageDelegates delegates = new PageDelegates ();
761 delegates.Load = ResolveClientUrl2_Load;
762 t.Invoker = new PageInvoker (delegates);
763 string html = t.Run ();
766 public static void ResolveClientUrl2_Load (Page p)
768 Control uc = p.FindControl ("WebUserControl1");
769 Control ctrl = uc.FindControl ("Label");
771 string url = ctrl.ResolveClientUrl ("~/MyPage.aspx");
772 Assert.AreEqual ("MyPage.aspx", url, "ResolveClientUrl Failed");
774 Assert.AreEqual ("", ctrl.ResolveClientUrl (""), "empty string");
776 Assert.AreEqual ("./", ctrl.ResolveClientUrl ("~"), "~");
777 Assert.AreEqual ("./", ctrl.ResolveClientUrl ("~/"), "~/");
779 Assert.AreEqual ("../MyPage.aspx", ctrl.ResolveClientUrl ("~/../MyPage.aspx"), "~/../MyPage.aspx");
780 Assert.AreEqual ("../MyPage.aspx", ctrl.ResolveClientUrl ("~\\..\\MyPage.aspx"), "~\\..\\MyPage.aspx");
781 Assert.AreEqual ("MyPage.aspx", ctrl.ResolveClientUrl ("~////MyPage.aspx"), "ResolveClientUrl Failed");
782 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveClientUrl ("/MyPage.aspx"), "ResolveClientUrl Failed");
783 Assert.AreEqual ("/folder/MyPage.aspx", ctrl.ResolveClientUrl ("/folder/MyPage.aspx"), "ResolveClientUrl Failed");
784 Assert.AreEqual ("/NunitWeb/MyPage.aspx", ctrl.ResolveClientUrl ("/NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
785 Assert.AreEqual ("\\NunitWeb/MyPage.aspx", ctrl.ResolveClientUrl ("\\NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
786 Assert.AreEqual ("///NunitWeb\\..\\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 ("Folder/MyPage.aspx", ctrl.ResolveClientUrl ("NunitWeb/../MyPage.aspx"), "ResolveClientUrl Failed");
789 Assert.AreEqual ("Folder/NunitWeb/MyPage.aspx", ctrl.ResolveClientUrl ("NunitWeb/./MyPage.aspx"), "ResolveClientUrl Failed");
790 Assert.AreEqual ("http://google.com/", ctrl.ResolveClientUrl ("http://google.com/"), "ResolveClientUrl Failed");
792 Assert.AreEqual ("MyPage.aspx?param=val&yes=no", ctrl.ResolveClientUrl ("~/MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
793 Assert.AreEqual ("../MyPage.aspx?param=val&yes=no", ctrl.ResolveClientUrl ("~/../MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
795 Assert.AreEqual ("Folder/MyPage.aspx", ctrl.ResolveClientUrl ("./MyPage.aspx"), "ResolveClientUrl Failed");
796 Assert.AreEqual ("MyPage.aspx", ctrl.ResolveClientUrl ("../MyPage.aspx"), "ResolveClientUrl Failed");
801 [Category ("NunitWeb")]
802 public void ResolveUrl ()
804 WebTest t = new WebTest (PageInvoker.CreateOnLoad (ResolveUrl_Load));
805 string html = t.Run ();
808 public static void ResolveUrl_Load (Page p)
810 string appPath = "/NunitWeb";
811 Control ctrl = new Control ();
812 p.Controls.Add (ctrl);
813 Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("~/MyPage.aspx"), "ResolveClientUrl Failed");
815 Assert.AreEqual ("", ctrl.ResolveUrl (""), "empty string");
817 Assert.AreEqual (appPath + "/", ctrl.ResolveUrl ("~"), "~");
818 Assert.AreEqual (appPath + "/", ctrl.ResolveUrl ("~/"), "~/");
820 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("~/../MyPage.aspx"), "~/../MyPage.aspx");
821 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("~\\..\\MyPage.aspx"), "~\\..\\MyPage.aspx");
822 Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("~////MyPage.aspx"), "ResolveClientUrl Failed");
823 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("/MyPage.aspx"), "ResolveClientUrl Failed");
824 Assert.AreEqual ("/folder/MyPage.aspx", ctrl.ResolveUrl ("/folder/MyPage.aspx"), "ResolveClientUrl Failed");
825 Assert.AreEqual ("/NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("/NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
826 Assert.AreEqual ("\\NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("\\NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
827 Assert.AreEqual ("///NunitWeb\\..\\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 (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("NunitWeb/../MyPage.aspx"), "ResolveClientUrl Failed");
830 Assert.AreEqual (appPath + "/NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("NunitWeb/./MyPage.aspx"), "ResolveClientUrl Failed");
831 Assert.AreEqual ("http://google.com/", ctrl.ResolveUrl ("http://google.com/"), "ResolveClientUrl Failed");
833 Assert.AreEqual (appPath + "/MyPage.aspx?param=val&yes=no", ctrl.ResolveUrl ("~/MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
834 Assert.AreEqual ("/MyPage.aspx?param=val&yes=no", ctrl.ResolveUrl ("~/../MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
836 Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("./MyPage.aspx"), "ResolveClientUrl Failed");
837 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("../MyPage.aspx"), "ResolveClientUrl Failed");
839 Assert.AreEqual ("/", ctrl.ResolveUrl (".."), "..");
840 Assert.AreEqual ("/", ctrl.ResolveUrl ("../"), "../");
844 [Category ("NunitWeb")]
845 public void ResolveUrl2 ()
847 WebTest t = new WebTest ("ResolveUrl.aspx");
848 PageDelegates delegates = new PageDelegates ();
849 delegates.Load = ResolveUrl2_Load;
850 t.Invoker = new PageInvoker (delegates);
851 string html = t.Run ();
854 public static void ResolveUrl2_Load (Page p)
856 string appPath = "/NunitWeb";
857 Control uc = p.FindControl ("WebUserControl1");
858 Control ctrl = uc.FindControl ("Label");
860 Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("~/MyPage.aspx"), "ResolveClientUrl Failed");
862 Assert.AreEqual ("", ctrl.ResolveUrl (""), "empty string");
864 Assert.AreEqual (appPath + "/", ctrl.ResolveUrl ("~"), "~");
865 Assert.AreEqual (appPath + "/", ctrl.ResolveUrl ("~/"), "~/");
867 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("~/../MyPage.aspx"), "~/../MyPage.aspx");
868 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("~\\..\\MyPage.aspx"), "~\\..\\MyPage.aspx");
869 Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("~////MyPage.aspx"), "ResolveClientUrl Failed");
870 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("/MyPage.aspx"), "ResolveClientUrl Failed");
871 Assert.AreEqual ("/folder/MyPage.aspx", ctrl.ResolveUrl ("/folder/MyPage.aspx"), "ResolveClientUrl Failed");
872 Assert.AreEqual ("/NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("/NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
873 Assert.AreEqual ("\\NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("\\NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
874 Assert.AreEqual ("///NunitWeb\\..\\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 (appPath + "/Folder/MyPage.aspx", ctrl.ResolveUrl ("NunitWeb/../MyPage.aspx"), "ResolveClientUrl Failed");
877 Assert.AreEqual (appPath + "/Folder/NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("NunitWeb/./MyPage.aspx"), "ResolveClientUrl Failed");
878 Assert.AreEqual ("http://google.com/", ctrl.ResolveUrl ("http://google.com/"), "ResolveClientUrl Failed");
880 Assert.AreEqual (appPath + "/MyPage.aspx?param=val&yes=no", ctrl.ResolveUrl ("~/MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
881 Assert.AreEqual ("/MyPage.aspx?param=val&yes=no", ctrl.ResolveUrl ("~/../MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
883 Assert.AreEqual (appPath + "/Folder/MyPage.aspx", ctrl.ResolveUrl ("./MyPage.aspx"), "ResolveClientUrl Failed");
884 Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("../MyPage.aspx"), "ResolveClientUrl Failed");
886 Assert.AreEqual (appPath + "/", ctrl.ResolveUrl (".."), "..");
887 Assert.AreEqual (appPath + "/", ctrl.ResolveUrl ("../"), "../");
888 Assert.AreEqual ("/", ctrl.ResolveUrl ("../.."), "../..");
889 Assert.AreEqual ("/", ctrl.ResolveUrl ("../../"), "../../");
890 Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("../../MyPage.aspx"), "../../MyPage.aspx");
894 [Category ("NotWorking")] // Not implemented exception
895 public void ResolveAdapter_2 ()
897 DerivedControl ctrl = new DerivedControl ();
898 Assert.AreEqual (null, ctrl.ResolveAdapter (), "ResolveAdapter");
902 public void EnableTheming ()
904 DerivedControl ctrl = new DerivedControl ();
905 Assert.AreEqual (true, ctrl.EnableTheming, "EnableTheming#1");
906 ctrl.EnableTheming = false;
907 Assert.AreEqual (false, ctrl.EnableTheming, "EnableTheming#2");
911 public void BindingContainer ()
913 ControlWithTemplate c = new ControlWithTemplate ();
914 c.Template = new CompiledTemplateBuilder (new BuildTemplateMethod (BindingContainer_BuildTemplate));
916 // cause CreateChildControls called
917 c.FindControl ("stam");
920 static void BindingContainer_BuildTemplate (Control control)
922 Control child1 = new Control ();
923 control.Controls.Add (child1);
925 Assert.IsTrue (Object.ReferenceEquals (child1.NamingContainer, control), "NamingContainer #1");
926 Assert.IsTrue (Object.ReferenceEquals (child1.BindingContainer, control), "BindingContainer #1");
928 NamingContainer nc = new NamingContainer ();
929 Control child2 = new Control ();
930 nc.Controls.Add (child2);
931 control.Controls.Add (nc);
933 Assert.IsTrue (Object.ReferenceEquals (child2.NamingContainer, nc), "NamingContainer #2");
934 Assert.IsTrue (Object.ReferenceEquals (child2.BindingContainer, nc), "BindingContainer #2");
936 // DetailsViewPagerRow marked to be not BindingContainer
937 DetailsViewPagerRow row = new DetailsViewPagerRow (0, DataControlRowType.Pager, DataControlRowState.Normal);
938 TableCell cell = new TableCell ();
939 Control child3 = new Control ();
940 cell.Controls.Add (child3);
941 row.Cells.Add (cell);
942 control.Controls.Add (row);
944 Assert.IsTrue (Object.ReferenceEquals (child3.NamingContainer, row), "NamingContainer #3");
945 Assert.IsTrue (Object.ReferenceEquals (child3.BindingContainer, control), "BindingContainer #3");
948 public void Control_Adapter ()
950 MyNC ctr = new MyNC ();
951 Assert.AreEqual (null, ctr.Adapter (), "Adapter");
954 public void ChildControlsCreated () {
955 ChildControlsCreatedControl ctr = new ChildControlsCreatedControl ();
956 ctr.Controls.Add (new Control ());
957 //ctr.DoEnsureChildControls ();
959 Assert.AreEqual (1, ctr.Controls.Count, "ChildControlsCreated#1");
960 ctr.SetChildControlsCreated (false);
961 Assert.AreEqual (1, ctr.Controls.Count, "ChildControlsCreated#2");
964 [Test (Description="Bug #594238")]
965 public void OverridenControlsPropertyAndPostBack_Bug594238 ()
967 WebTest t = new WebTest ("OverridenControlsPropertyAndPostBack_Bug594238.aspx");
970 FormRequest fr = new FormRequest (t.Response, "form1");
971 fr.Controls.Add ("__EVENTTARGET");
972 fr.Controls.Add ("__EVENTARGUMENT");
973 fr.Controls ["__EVENTTARGET"].Value = "container$children$lb";
974 fr.Controls ["__EVENTARGUMENT"].Value = String.Empty;
977 string originalHtml = "<span id=\"container\"><a id=\"container_children_lb\" href=\"javascript:__doPostBack('container$children$lb','')\">Woot! I got clicked!</a></span><hr/>";
979 string originalHtml = @"<span id=""container""><a href=""javascript:__doPostBack('container$children$lb','')"" id=""container_children_lb"">Woot! I got clicked!</a></span><hr/>";
981 string pageHtml = t.Run ();
982 string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
984 HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
987 [TestFixtureTearDown]
988 public void Tear_down ()
994 public void TestFixtureSetUp ()
996 WebTest.CopyResource (GetType (), "ResolveUrl.aspx", "ResolveUrl.aspx");
997 WebTest.CopyResource (GetType (), "ResolveUrl.ascx", "Folder/ResolveUrl.ascx");
998 WebTest.CopyResource (GetType (), "OverridenControlsPropertyAndPostBack_Bug594238.aspx", "OverridenControlsPropertyAndPostBack_Bug594238.aspx");
1003 public void GetRouteUrl_Object ()
1005 var t = new WebTest (PageInvoker.CreateOnLoad (GetRouteUrl_Object_Load));
1009 public static void GetRouteUrl_Object_Load (Page p)
1011 RouteTable.Routes.Clear ();
1013 var ctl = new Control ();
1014 object obj = new { foo = "one", bar = "two" };
1015 string path = ctl.GetRouteUrl (obj);
1016 Assert.IsNull (path, "#A1");
1018 RouteTable.Routes.Add (new Route ("{foo}-{bar}", new PageRouteHandler ("~/default.aspx")));
1019 path = ctl.GetRouteUrl (obj);
1020 Assert.IsNotNull (path, "#A2-1");
1021 Assert.AreEqual ("/NunitWeb/one-two", path, "#A2-2");
1023 path = ctl.GetRouteUrl ((object)null);
1024 Assert.IsNull (path, "#A3");
1028 public void GetRouteUrl_RouteValueDictionary ()
1030 var t = new WebTest (PageInvoker.CreateOnLoad (GetRouteUrl_RouteValueDictionary_Load));
1034 public static void GetRouteUrl_RouteValueDictionary_Load (Page p)
1036 RouteTable.Routes.Clear ();
1038 var ctl = new Control ();
1039 var rvd = new RouteValueDictionary {
1043 string path = ctl.GetRouteUrl (rvd);
1044 Assert.IsNull (path, "#A1");
1046 RouteTable.Routes.Add (new Route ("{foo}-{bar}", new PageRouteHandler ("~/default.aspx")));
1047 path = ctl.GetRouteUrl (rvd);
1048 Assert.IsNotNull (path, "#A2-1");
1049 Assert.AreEqual ("/NunitWeb/one-two", path, "#A2-2");
1051 path = ctl.GetRouteUrl ((RouteValueDictionary) null);
1052 Assert.IsNull (path, "#A3");
1056 public void GetRouteUrl_String_Object ()
1058 var t = new WebTest (PageInvoker.CreateOnLoad (GetRouteUrl_String_Object_Load));
1062 public static void GetRouteUrl_String_Object_Load (Page p)
1064 RouteTable.Routes.Clear ();
1066 var ctl = new Control ();
1067 object obj = new { foo = "one", bar = "two" };
1069 AssertExtensions.Throws<ArgumentException> (() => {
1070 path = ctl.GetRouteUrl ("myroute1", obj);
1073 RouteTable.Routes.Add (new Route ("{foo}-{bar}", new PageRouteHandler ("~/default.aspx")));
1074 RouteTable.Routes.Add ("myroute1", new Route ("{bar}-{foo}", new PageRouteHandler ("~/default.aspx")));
1075 path = ctl.GetRouteUrl ("myroute1", obj);
1076 Assert.IsNotNull (path, "#A2-1");
1077 Assert.AreEqual ("/NunitWeb/two-one", path, "#A2-2");
1079 path = ctl.GetRouteUrl ("myroute1", (object) null);
1080 Assert.IsNull (path, "#A3");
1084 public void GetRouteUrl_String_RouteValueDictionary ()
1086 var t = new WebTest (PageInvoker.CreateOnLoad (GetRouteUrl_String_RouteValueDictionary_Load));
1090 public static void GetRouteUrl_String_RouteValueDictionary_Load (Page p)
1092 RouteTable.Routes.Clear ();
1094 var ctl = new Control ();
1095 var rvd = new RouteValueDictionary {
1100 AssertExtensions.Throws<ArgumentException> (() => {
1101 path = ctl.GetRouteUrl ("myroute", rvd);
1104 RouteTable.Routes.Add (new Route ("{foo}-{bar}", new PageRouteHandler ("~/default.aspx")));
1105 RouteTable.Routes.Add ("myroute", new Route ("{bar}-{foo}", new PageRouteHandler ("~/default.aspx")));
1106 path = ctl.GetRouteUrl ("myroute", rvd);
1107 Assert.IsNotNull (path, "#A2-1");
1108 Assert.AreEqual ("/NunitWeb/two-one", path, "#A2-2");
1110 path = ctl.GetRouteUrl ("myroute", (RouteValueDictionary) null);
1111 Assert.IsNull (path, "#A3-1");
1113 path = ctl.GetRouteUrl (null, (RouteValueDictionary) null);
1114 Assert.IsNull (path, "#A3-2");
1116 path = ctl.GetRouteUrl (String.Empty, (RouteValueDictionary) null);
1117 Assert.IsNull (path, "#A3-3");
1121 class ControlWithState : Control
1127 get { return _state; }
1128 set { _state = value; }
1131 public string Viewstate {
1132 get { return (string) ViewState ["Viewstate"]; }
1133 set { ViewState ["Viewstate"] = value; }
1136 protected internal override void OnInit (EventArgs e)
1139 Page.RegisterRequiresControlState (this);
1142 protected internal override object SaveControlState ()
1147 protected internal override void LoadControlState (object savedState)
1149 State = (string) savedState;
1152 public new void ClearChildState ()
1154 base.ClearChildState ();
1157 public new void ClearChildControlState ()
1159 base.ClearChildControlState ();
1162 public new bool IsChildControlStateCleared
1164 get { return base.IsChildControlStateCleared; }
1167 public new bool LoadViewStateByID
1169 get { return base.LoadViewStateByID; }
1173 class MyNC : Control, INamingContainer
1175 public ControlAdapter Adapter ()
1177 return base.Adapter;
1180 public new void DataBind (bool opt)
1182 base.DataBind (opt);
1185 public new void DataBindChildren ()
1187 base.DataBindChildren ();
1190 public new void EnsureID ()
1195 public new bool HasEvents ()
1197 return base.HasEvents ();
1201 class DerivedControl : Control
1203 ControlCollection coll;
1205 public DerivedControl ()
1207 coll = new ControlCollection (this);
1210 public override ControlCollection Controls
1212 get { return coll; }
1215 public bool DoIsViewStateEnabled
1217 get { return IsViewStateEnabled; }
1220 public new char ClientIDSeparator
1222 get { return base.ClientIDSeparator; }
1225 public new char IdSeparator
1227 get { return base.IdSeparator; }
1230 public new Stream OpenFile (string path)
1232 return base.OpenFile (path);
1235 public new ControlAdapter ResolveAdapter ()
1237 return base.ResolveAdapter ();
1241 class NamingContainer : Control, INamingContainer
1245 class ControlWithTemplate : Control
1247 ITemplate _template;
1249 [TemplateContainer (typeof (TemplateContainer))]
1250 public ITemplate Template
1252 get { return _template; }
1253 set { _template = value; }
1256 protected internal override void CreateChildControls ()
1260 TemplateContainer container = new TemplateContainer ();
1261 Controls.Add (container);
1263 if (Template != null)
1264 Template.InstantiateIn (container);
1268 class TemplateContainer : Control, INamingContainer
1274 public class Customadaptercontrol : Control
1276 public new ControlAdapter Adapter {
1277 get { return base.Adapter; }
1280 public new ControlAdapter ResolveAdapter ()
1282 return base.ResolveAdapter ();
1286 public class Customadapter : ControlAdapter
1290 class EnsureIDControl : Control {
1291 public void DoEnsureID () {
1296 public class ChildControlsCreatedControl : Control
1298 protected internal override void CreateChildControls () {
1299 Controls.Add (new Control ());
1302 public void DoEnsureChildControls () {
1303 EnsureChildControls ();
1306 public void SetChildControlsCreated (bool value) {
1307 ChildControlsCreated = value;