asp:Image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • truezplaya
    New Member
    • Jul 2007
    • 115

    asp:Image

    Hey up
    Me again
    I am trying to display a single image on my web page using a asp:image tag

    Code:
    <asp:Image runat="server" id="picture one" AlternateText="SillyPicture" ImageUrl="C:\Users\username\sillypicture.jpg />
    Is there any reason why this shouldn't work. I am pretty new to asp.net so any input would possibly be a help
    Last edited by Frinavale; Feb 19 '09, 05:08 PM. Reason: fixed [code] tag
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    The reason this isn't working is because the image isn't located on the Web Server and therefore the web pages cannot access it.

    Place the image in your web application to be sure that it is on the web server.

    Comment

    • truezplaya
      New Member
      • Jul 2007
      • 115

      #3
      Sorry when you say in my web app do you mean in the same file as the web application.It doesn't seem to work:(. If you can point me to tutorials then thats helpful as well. I am running it through visual studio

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        I don't think tutorial will help you here (I doubt there is any for this).
        The only way that your web browser can access an image is if it exists on the web server...and you need to provide the image with a URL to locate the image on the server.

        Add the file to your web application via Visual Studio....


        Or better yet add a folder named "Images" to your web application via Visual Studio.
        Add the image to this folder.
        Then change your Image control so that it points to the URL of the image:
        Code:
        <asp:Image runat="server" id="picture one" AlternateText="SillyPicture" ImageUrl="~/Images/sillypicture.jpg /">
        -Frinny

        Comment

        • truezplaya
          New Member
          • Jul 2007
          • 115

          #5
          Cheers got it going now!

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            Awesome :)

            Comment

            Working...