Просмотр исходного кода

2006-12-06 Igor Zelmanovich <[email protected]>

	* AdRotator.cs: fixed: 
	MSDN: The ImageUrl and NavigateUrl attributes can be a full URL, a 
	root-relative path, or a relative path. If you use a root-relative path, 
	the path is relative to the same Web site. If you use a relative path, 
	the path is relative to the directory that contains the advertisement file.


svn path=/trunk/mcs/; revision=69116
Igor Zelmanovich 19 лет назад
Родитель
Сommit
abc4aa74a5

+ 19 - 7
mcs/class/System.Web/System.Web.UI.WebControls/AdRotator.cs

@@ -30,6 +30,7 @@ using System.Xml;
 using System.Collections;
 using System.ComponentModel;
 using System.Security.Permissions;
+using System.Web.Util;
 
 namespace System.Web.UI.WebControls {
 
@@ -105,16 +106,17 @@ namespace System.Web.UI.WebControls {
 			AdCreatedEventArgs e = createdargs;
 
 			base.AddAttributesToRender (w);
-			
-			if (e.NavigateUrl != null)
-				w.AddAttribute (HtmlTextWriterAttribute.Href, ResolveClientUrl (e.NavigateUrl));
-			w.AddAttribute (HtmlTextWriterAttribute.Target, Target);
+
+			if (e.NavigateUrl != null && e.NavigateUrl.Length > 0)
+				w.AddAttribute (HtmlTextWriterAttribute.Href, ResolveAdUrl (e.NavigateUrl));
+			if (Target != null && Target.Length > 0)
+				w.AddAttribute (HtmlTextWriterAttribute.Target, Target);
 			
 			w.RenderBeginTag (HtmlTextWriterTag.A);
 
-			if (e.NavigateUrl != null)
-				w.AddAttribute (HtmlTextWriterAttribute.Src, ResolveClientUrl (e.ImageUrl));
-			
+			if (e.NavigateUrl != null && e.NavigateUrl.Length > 0)
+				w.AddAttribute (HtmlTextWriterAttribute.Src, ResolveAdUrl (e.ImageUrl));
+
 			w.AddAttribute (HtmlTextWriterAttribute.Alt, e.AlternateText == null ? "" : e.AlternateText);
 			w.AddAttribute (HtmlTextWriterAttribute.Border, "0");
 			w.RenderBeginTag (HtmlTextWriterTag.Img);
@@ -122,6 +124,16 @@ namespace System.Web.UI.WebControls {
 			w.RenderEndTag (); // a
 		}
 
+		string ResolveAdUrl (string url)
+		{
+			string path = url;
+			
+			if (AdvertisementFile != null && AdvertisementFile.Length > 0 && path [0] != '/' && path [0] != '~')
+				return UrlUtils.Combine (UrlUtils.GetDirectory (ResolveUrl (AdvertisementFile)), path);
+			
+			return ResolveUrl (path);
+		}
+
 		//
 		// We take all the ads in the ad file and add up their
 		// impression weight. We then take a random number [0,

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

@@ -1,3 +1,11 @@
+2006-12-06 Igor Zelmanovich <[email protected]>
+
+	* AdRotator.cs: fixed: 
+	MSDN: The ImageUrl and NavigateUrl attributes can be a full URL, a 
+	root-relative path, or a relative path. If you use a root-relative path, 
+	the path is relative to the same Web site. If you use a relative path, 
+	the path is relative to the directory that contains the advertisement file.
+
 2006-12-06 Igor Zelmanovich <[email protected]>
 
 	* BaseCompareValidator.cs: fixed: support for type=Date on client side.