Browse Source

2007-07-02 Marek Habersack <[email protected]>

	* Control.cs: make sure TemplateSourceDirectory returns meaningful
	results in the 1.1 profile. Fixes bug #81950.

svn path=/trunk/mcs/; revision=81163
Marek Habersack 18 years ago
parent
commit
8f43bfc166

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

@@ -1,3 +1,8 @@
+2007-07-02  Marek Habersack  <[email protected]>
+
+	* Control.cs: make sure TemplateSourceDirectory returns meaningful
+	results in the 1.1 profile. Fixes bug #81950.
+
 2007-06-24  Vladimir Krasnov  <[email protected]>
 
 	* ObjectStateFormatter.cs: WriterContext.RegisterCache, refactored out

+ 13 - 2
mcs/class/System.Web/System.Web.UI/Control.cs

@@ -109,8 +109,9 @@ namespace System.Web.UI
 #if NET_2_0
 		TemplateControl _templateControl;
 		bool _isChildControlStateCleared;
-		string _templateSourceDirectory;
 #endif
+		string _templateSourceDirectory;
+		
 		/*************/
 		int stateMask;
 		const int ENABLE_VIEWSTATE 	= 1;
@@ -437,7 +438,17 @@ namespace System.Web.UI
 				
 				return _templateSourceDirectory;
 #else
-				return (_parent == null) ? String.Empty : _parent.TemplateSourceDirectory;
+				if (_templateSourceDirectory == null) {
+					HttpContext ctx = HttpContext.Current;
+					HttpRequest req = ctx != null ? ctx.Request : null;
+					
+					_templateSourceDirectory = (_parent == null)
+						? req != null ? VirtualPathUtility.RemoveTrailingSlash (
+							VirtualPathUtility.GetDirectory (
+								HttpContext.Current.Request.CurrentExecutionFilePath)) : String.Empty
+						: _parent.TemplateSourceDirectory;
+				}
+				return _templateSourceDirectory;
 #endif
 			}
                 }