Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. Display Image from Path

Display Image from Path

Scheduled Pinned Locked Moved Web Development
helptutorialquestion
10 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nudma
    wrote on last edited by
    #1

    Hi!!! I am trying to display image from C and D drive using following code. The code is very simple. Here it is:

    protected void Page_Load(object sender, EventArgs e)
    {
    Response.Write ("<table border='1'>");
    Response.Write ("<tr>");
    Response.Write ("<td><img src='D:\at.jpg'></td>");
    Response.Write ("<td><img src='C:\try.jpg'></td>") ;
    Response.Write ("</tr>" );
    Response.Write("</table>");
    }

    I neither get image on page nor error message. How could i resolve it?Please guide me...

    S 1 Reply Last reply
    0
    • N nudma

      Hi!!! I am trying to display image from C and D drive using following code. The code is very simple. Here it is:

      protected void Page_Load(object sender, EventArgs e)
      {
      Response.Write ("<table border='1'>");
      Response.Write ("<tr>");
      Response.Write ("<td><img src='D:\at.jpg'></td>");
      Response.Write ("<td><img src='C:\try.jpg'></td>") ;
      Response.Write ("</tr>" );
      Response.Write("</table>");
      }

      I neither get image on page nor error message. How could i resolve it?Please guide me...

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      Hi, this won't work since the client doesn't know anything about files on the servers disk. What you have to do is to put an URL into the src-tag (e.g. http://myserver.com/images/at.jpg). I suggest to create an image folder within your ASP.NET Website (name it images), then add all images you want to display to this folder and replace the value in the img-src tag with 'images/at.jpg' or 'images/try.jpg'. Let me know if this helps you. Regards Sebastian

      It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

      N 2 Replies Last reply
      0
      • S SeMartens

        Hi, this won't work since the client doesn't know anything about files on the servers disk. What you have to do is to put an URL into the src-tag (e.g. http://myserver.com/images/at.jpg). I suggest to create an image folder within your ASP.NET Website (name it images), then add all images you want to display to this folder and replace the value in the img-src tag with 'images/at.jpg' or 'images/try.jpg'. Let me know if this helps you. Regards Sebastian

        It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

        N Offline
        N Offline
        nudma
        wrote on last edited by
        #3

        yeah offcourse it worked... Thankyou for helping me...

        1 Reply Last reply
        0
        • S SeMartens

          Hi, this won't work since the client doesn't know anything about files on the servers disk. What you have to do is to put an URL into the src-tag (e.g. http://myserver.com/images/at.jpg). I suggest to create an image folder within your ASP.NET Website (name it images), then add all images you want to display to this folder and replace the value in the img-src tag with 'images/at.jpg' or 'images/try.jpg'. Let me know if this helps you. Regards Sebastian

          It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

          N Offline
          N Offline
          nudma
          wrote on last edited by
          #4

          I assign image path to some string variable like this:

          string path = "C:\at.jpg";

          and apply this:

          protected void Page_Load(object sender, EventArgs e)
          {
          Response.Write(@"<table border='1'>");
          Response.Write(@"<tr>");
          Response.Write(@"<td><img src=path></td>");
          Response.Write(@"<td><img src='D:\try.jpg'></td>");
          Response.Write(@"</tr>");
          Response.Write(@"</table>");
          }

          Then it does not display image neither it shows any error message. Why so?Please help..

          S 1 Reply Last reply
          0
          • N nudma

            I assign image path to some string variable like this:

            string path = "C:\at.jpg";

            and apply this:

            protected void Page_Load(object sender, EventArgs e)
            {
            Response.Write(@"<table border='1'>");
            Response.Write(@"<tr>");
            Response.Write(@"<td><img src=path></td>");
            Response.Write(@"<td><img src='D:\try.jpg'></td>");
            Response.Write(@"</tr>");
            Response.Write(@"</table>");
            }

            Then it does not display image neither it shows any error message. Why so?Please help..

            S Offline
            S Offline
            SeMartens
            wrote on last edited by
            #5

            As i mentioned in the post before do the following: 1. create a folder called images in your Application folder (where your website is) 2. copy the try.jpg to this folder 3. rewrite your code to this:

            Reponse.Write(@"<td><img src='images\try.jpg'></td>");

            The browser (client side) does not provide an error when it couldn't find the image file.

            It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

            N 1 Reply Last reply
            0
            • S SeMartens

              As i mentioned in the post before do the following: 1. create a folder called images in your Application folder (where your website is) 2. copy the try.jpg to this folder 3. rewrite your code to this:

              Reponse.Write(@"<td><img src='images\try.jpg'></td>");

              The browser (client side) does not provide an error when it couldn't find the image file.

              It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

              N Offline
              N Offline
              nudma
              wrote on last edited by
              #6

              I understood your point, did the same and got the accurate results too.. but now i want to assign that image path to some variable and then want to assign that variable to src..as i said in my last message... Guide me for this please!!!

              S 1 Reply Last reply
              0
              • N nudma

                I understood your point, did the same and got the accurate results too.. but now i want to assign that image path to some variable and then want to assign that variable to src..as i said in my last message... Guide me for this please!!!

                S Offline
                S Offline
                SeMartens
                wrote on last edited by
                #7

                Well than just do that: string sImage = "images/try.jpg"; ... ... Response.Write(@"<td><img src='" + sImage + "'></td>");

                It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

                N 2 Replies Last reply
                0
                • S SeMartens

                  Well than just do that: string sImage = "images/try.jpg"; ... ... Response.Write(@"<td><img src='" + sImage + "'></td>");

                  It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

                  N Offline
                  N Offline
                  nudma
                  wrote on last edited by
                  #8

                  Thankyou it worked!!!

                  1 Reply Last reply
                  0
                  • S SeMartens

                    Well than just do that: string sImage = "images/try.jpg"; ... ... Response.Write(@"<td><img src='" + sImage + "'></td>");

                    It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

                    N Offline
                    N Offline
                    nudma
                    wrote on last edited by
                    #9

                    Semartens!! I want to vote your answer..How can i do that?

                    S 1 Reply Last reply
                    0
                    • N nudma

                      Semartens!! I want to vote your answer..How can i do that?

                      S Offline
                      S Offline
                      SeMartens
                      wrote on last edited by
                      #10

                      When you view my response, click at one of the numbers at the bottom right side of the message (labeled with "Rate this message") (1 is bad, 5 is good) :) Thanks for voting :) This will mark your message as answered. Regards Sebastian

                      It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups