Mike Hankey

Mike Hankey

  • NA
  • 81
  • 0

Server.MapPath and image problem

Apr 23 2008 10:20 AM
Hey y'all,

I am uploading a file to a directory in my root named "Pictures" and it works fine.  
I also add a title , url, and name of the picture in a XmlDatasource, and this works fine.

In my masterPage.master file I have;

[div id="image-area"]
      [a id="linkPart" runat="server" href="http://www.pic_site.com]
      [img id="imagePart" runat="server" src="pictures/pic.jpg" alt="Image of the Day" /][/a]
      [p id="captionPart" runat="server">The rules according to Luna[/p]
[/div]

<b>Note: As this is my first post I have replaced the "<>" with "[]" just in case no handled!</b>

And in my masterPage.master.cs code behind file I have;

                  XmlNode elem = GetRandomPictureNode();
                  linkPart.HRef = elem.SelectSingleNode("url").InnerText;
                  str = elem.SelectSingleNode("file").InnerText;
                  string path = Server.MapPath("~/pictures/");
                  imagePart.Src = path + str;
                  captionPart.InnerText = elem.SelectSingleNode("title").InnerText;

The value that gets put into .Src is correct but the image doesn't display I get the alt "Image of the Day" instead?

P.S. The link and title work fine its just the image that doesn't work!

What the heck have I overlooked or don't understand?
Any help appreciated!
Mike

Answers (2)