有一个AdRotator控件<asp:AdRotator ID="ad" runat="server" Target="_blank"
                                   AdvertisementFile="ads.xml" OnAdCreated="ad_AdCreated" />,
在网面中显示出来后,点击总是跳转到
http://localhost/ads/%20%20%20%20%20%20http://www.oreilly.com/catalog/progvb2005/%20%20%20%20,而应该跳转到http://www.oreilly.com/catalog/progvb2005/%20%20%20%20才对,请教各位是什么问题?

解决方案 »

  1.   

    ads.xml 路径 你写死 http://www.oreilly.com/catalog/progvb2005/%
    或者加一个 ~在你的路径前面
      

  2.   

    ads.xml怎么写的?OnAdCreated="ad_AdCreated"里面干了什么事情?
      

  3.   

    http://localhost/ads/%20%20%20%20%20%20多余或者
    head节点加 base 元素控制
     <base href='<%= this.Request.Url.Scheme + "://" + this.Request.Url.Host + ":" + this.Request.Url.Port + this.Request.ApplicationPath +"/"%>' />
      

  4.   

    整个程序是这样的:
    // Default.aspx:
    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <h1>
                AdRotator Control</h1>
            <br />
            <asp:AdRotator ID="ad" runat="server" AdvertisementFile="~/ads.xml" OnAdCreated="ad_AdCreated"
                Target="_blank" />
            <br />
            <asp:Label ID="lblAnimal" runat="server"></asp:Label></div>
        </form>
    </body>
    </html>// Default.aspx.cs:
    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {    }
        protected void ad_AdCreated(object sender, AdCreatedEventArgs e)
        {
            if ((string)e.AdProperties["Animial"] != "")
                lblAnimal.Text = (string)e.AdProperties["Animal"];
            else
                lblAnimal.Text = "n.a.";
                
        }
    }
      

  5.   

    // ads.xml
    <?xml version="1.0" encoding="utf-8" ?><Advertisements>
      <Ad>
        <ImageUrl>ProgAspNet.gif</ImageUrl>
        <NavigateUrl>
          http://www.oreilly.com/catalog/progaspdotnet2/index.html
        </NavigateUrl>
        <AlternateText>Programming ASP.NET</AlternateText>
        <Keyword>Web</Keyword>
        <Impressions>50</Impressions>
        <Animal>stingray</Animal>
      </Ad>  <Ad>
        <ImageUrl>WinApps.gif</ImageUrl>
        <NavigateUrl>
          http://www.oreilly.com/catalog/pnetwinaps/index.html
        </NavigateUrl>
        <AlternateText>Programming .NET Windows Applications</AlternateText>
        <Keyword>Windows</Keyword>
        <Impressions>40</Impressions>
        <Animal>darter</Animal>
      </Ad>  <Ad>
        <ImageUrl>ProgCSharp.gif</ImageUrl>
        <NavigateUrl>
          http://www.oreilly.com/catalog/progcsharp4/
        </NavigateUrl>
        <AlternateText>Programming C#</AlternateText>
        <Keyword>Language</Keyword>
        <Impressions>40</Impressions>
        <Animal>African Crowned Crane</Animal>
      </Ad>  <Ad>
        <ImageUrl>ProgVB.gif</ImageUrl>
        <NavigateUrl>
          http://www.oreilly.com/catalog/progvb2005/
        </NavigateUrl>
        <AlternateText>Programming Visual Basic 2005</AlternateText>
        <Keyword>Language</Keyword>
        <Impressions>30</Impressions>
        <Animal>catfish</Animal>
      </Ad></Advertisements>
      

  6.   

    wxr0323:
      你说的head节点加 base 元素控制没用啊,还是有http://localhost/ads/%20%20%20%20%20%20多余
      

  7.   

    原因是这样的:你的xml 文件里面 NavigateUrl节点有空格改成这样的就可以了
    <NavigateUrl>http://www.oreilly.com/catalog/progaspdotnet2/index.html</NavigateUrl>
      

  8.   

    net_lover:
        果然像你所说的,不愧是高手,这个错误都能被你找出来.