Jelajahi Sumber

2007-06-06 Marek Habersack <[email protected]>

	* Control.cs: more changes to the way TemplateSourceDirectory
	works in the 2.0 profile. Take into account situations when a
	control is placed in a UserControl (.ascx) and only then fall back
	to the parent for its TemplateSourceDirectory.

svn path=/trunk/mcs/; revision=78731
Marek Habersack 18 tahun lalu
induk
melakukan
2addefc24d

+ 7 - 0
mcs/class/System.Web/System.Web.UI/ChangeLog

@@ -1,3 +1,10 @@
+2007-06-06  Marek Habersack  <[email protected]>
+
+	* Control.cs: more changes to the way TemplateSourceDirectory
+	works in the 2.0 profile. Take into account situations when a
+	control is placed in a UserControl (.ascx) and only then fall back
+	to the parent for its TemplateSourceDirectory.
+
 2007-06-05  Marek Habersack  <[email protected]>
 
 	* Control.cs: TemplateSourceDirectory uses TemplateControl to

+ 7 - 1
mcs/class/System.Web/System.Web.UI/Control.cs

@@ -398,7 +398,13 @@ namespace System.Web.UI
                 public virtual string TemplateSourceDirectory {
 			get {
 #if NET_2_0
-				return (_templateControl == null) ? String.Empty : _templateControl.TemplateSourceDirectory;
+				if (_templateControl != null)
+					return _templateControl.TemplateSourceDirectory;
+
+				// Arguably, a hack, but this is the easiest way of doing it. We must be sure that controls placed
+				// in an .ascx file get their source directory right, or otherwise ResolveClientUrl will return
+				// invalid paths in such situations.
+				return (_parent == null || !(_parent is UserControl)) ? String.Empty : _parent.TemplateSourceDirectory;
 #else
 				return (_parent == null) ? String.Empty : _parent.TemplateSourceDirectory;
 #endif