shhu1919

Request.ApplicationPath

有时候在用户控件中牵涉到文件/图片路径问题时就可以用这个方法来解决问题:

url=Request.ApplicationPath+"/images/banner_fj.jpg";

另外,后台控制 更改用户控件中图片的路径时可以用
        this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(),
            "a", "<script>document.getElementById(\'divbg\').style.backgroundImage=\'url(" + Request.ApplicationPath + ResourceConfig.backGroundImage_Top_Url + ")\';</script>");

但是发布网站后可能会出现一些问题,图片也会因为路径没有取对而显示不出来,绝对可行解决方法:

发布后的网站地址+图片相对路径,如:http://1.0.0.1:1212/pic/pic.jpg.

分类:

技术点:

相关文章: