Image not showing on the browser(asp.net)
  • I wrote this code :
     <div id="imageholder">
            <% foreach (var o in photos){ %>
                <img src='<%=ConfigurationManager.AppSettings["UploadedFilesDirectory"]+o.filePath %>' alt="No Images"/><br/>
              <% } %>
         </div> 
    And the value of ConfigurationManager.AppSettings["UploadedFilesDirectory"] is ~/uploadedFiles
    but the image does not show up on firefox.

  • 3 Comments sorted by
  • check the value of o.filePath after merge is making proper path or not.
  • I used asp.net image control with some code and it worked.Here is the code behind:
     protected void Page_Load(object sender, EventArgs e)
            {
                 int inspectionId = Convert.ToInt32(Request["id"]);
                 string sourcePath = ConfigurationManager.AppSettings["UploadedFilesDirectory"];
          
                string empty="No Image Available";
                if (inspectionId > 0)
                {
                    IEnumerable<InspectionPhotographs> photos = InspectionsRepository.GetInspectionPhotographs(inspectionId);
                    foreach (var x in photos)
                    {
                        
                        Image1.ImageUrl = Path.Combine(sourcePath, x.filePath);
                        Response.Write("<br/>");
                    }
                }
                else
                {
                    Image1.AlternateText = empty;
                }
            }

  • thanks for your feedback hope it will help for others.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Tagged

Popular Posts of the Week

Optimum Creative