locked
How to display a jpg image in Image Control RRS feed

  • Question

  • User756257866 posted
    I have Image control on a web form and i was a write a following code for displaying image in image control. but it does not display image in image control at runtime. Image1.ImageUrl = "c:\My Documents\IMG_0510.jpg"
    Monday, July 7, 2008 6:34 AM

Answers

  • User756257866 posted
    I got the solution just one change in code of replacing forward slash to backward slash Image1.ImageUrl = "c:/My Documents/IMG_0510.jpg"
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 7, 2008 7:07 AM

All replies

  • User756257866 posted
    I got the solution just one change in code of replacing forward slash to backward slash Image1.ImageUrl = "c:/My Documents/IMG_0510.jpg"
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 7, 2008 7:07 AM
  • User-126497635 posted

     I would like to suggest you that don't use the physical path for display image in image control. So you can use like that:-

    If you are using Runat = "server" control so you can use this one. 

    <asp:Image ID="ImageDisplay" ImageUrl="~/Image/xyz.gif" runat="server" />

     If you are using just HTML control so you can use this one.

    <img src="../Image/xyz.gif"/>

     You can change the folder name ("Images").

     

     

     

    Monday, July 7, 2008 7:14 AM