自定义控件上的图片,不同的目录看不到,只看到叉,具体我解释一下
我在自定义控件里设置图上片的路径是 Admin/Images/logo.jpg , 如果是同一个目录WEB窗体引用,是会有图片出来的, 如果是不同的目录,这个图片就看不到了,这个问题怎么解决呢,

解决方案 »

  1.   


    <body>
        <form id="form1" runat="server">
            <asp:ImageButton ID="ImageButton1" runat="server" />   
        </form>
    </body>
        protected void Page_Load(object sender, EventArgs e)
        {
            string strBaseUrl = string.Empty;
            string strSitePath = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);
            string strAppPath = HttpContext.Current.Request.ApplicationPath;
            if (strAppPath == null || strAppPath == "/")
            {
                strBaseUrl = strSitePath;
            }
            else
            {
                strBaseUrl = strSitePath + strAppPath;
            }
            string strImageUrl = strBaseUrl + @"\image\a.jpg";
            this.ImageButton1.ImageUrl = strImageUrl;
        }
      

  2.   

    就是路径啊http://gb2013.blog.163.com/blog/static/217353012010011105911158/