image not displaying when runat="server" is set
i have an image as such:
<img src="../pics/img.gif" runat="server" id="imgID" alt="Close" />
the image is not displayed unless i remo开发者_C百科ved the runat="server".
is there any reason for this behavior?It must be calling Control.ResolveClientUrl and ending up with the wrong path. If you look at the HTML source you'll probably figure out what's going wrong.
Try
<img src="~/pics/img.gif" runat="server" id="imgID" alt="Close" />
to set the path relative to the project root.
try
<asp:image ImageUrl="~/pics/img.gif" runat="server" ID="imgID" AlternateText="Close" />
I suspect this is a permissions problem.
I have a project called mkds which is located at C:\web\mkdata\mkds. I also have a large set of images located at c:\Icons. I did not want to include the images within the project as they dont change very often and it makes backups less convenient if they are included.
In VS 2008 if you set image1.imageUrl=c:\Icons.pic1.jpg you can see the image in the designer but you cannot see it when the page runs using the inbuilt web server. If the image is copied to c:\web\mkdata\mkds\Icons and the URL is set with image1.image="~\Icons\pic1.jpg" then you see it in designer and also when run with the built in web server.
If you select the image in designer, look at properties, and click the ellipsis button in ImageURl then VS gives you a selection of folders to select your image from, but they are all subfolders under the project directory.
精彩评论