Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Images not loading in ASP.NET app on my local machine

Avatar of skaleem1
skaleem1Flag for Canada asked on
.NET ProgrammingC#Microsoft SQL Server 2005
3 Comments1 Solution728 ViewsLast Modified:
I have a web app developed using ASP.NET, C# and javascript that speaks to SQL Sever in the back end. I have a web page that loads images for a specific product based on the image file path stored in one of the database table column as follows:

C:\Photos\HDK-24567-003 (1200 Paper, Dark Blue)[HB]-1.jpg

The Photos folder is residing on the same server where the App is deployed to and running on and the images are correctly loaded in the deployed web app. I made sure that the same folder (C:\Photos\) is created on my local machine on C: drive so that I can load those images while running the app on my local machine using Visual Studio. However, the images do not load at all. I made sure that the folder is shared and is accessible to the app (full control). What can be the reason? See the code section to show how am I loading those images:
private void DisplayAllPartImages()
        {
            //we retrieve data only if it is not in the session or a part is deleted
            if ((Session["dsPartPhotos"] == null) || (HProcessFileDelete.Value == "true"))
            {
                LoadData();
            }

            if(Session["dsPartPhotos"] !=null)
                dsPartPhotos = (DataSet)Session["dsPartPhotos"];

            if (dsPartPhotos == null)
                return;
            
            string  imageName=string.Empty;
            string imageNameCopy = string.Empty;

            string imageSrc = "";
            string imageURL = "";


            for (int i = 0; i < dsPartPhotos.Tables[IMAGES].Rows.Count; i++)
            {
                Panel oPanel = new Panel();
                Image oImage = new Image();

                oImage.CssClass = "ImageBorderStyleColor";
                oPanel.Width = 97;
                oPanel.Height = 97;
                oPanel.CssClass = "BorderStyleColor";
                oPanel.BorderStyle = System.Web.UI.WebControls.BorderStyle.Ridge;
                oImage.ID = dsPartPhotos.Tables[IMAGES].Rows[i]["HWDetailsID"].ToString();
                oPanel.CssClass = "BorderStyleColor";

                Session["ImageWidth"] = 500;
                Session["ImageHeight"] = 500;

                imageURL = string.Format("~/PicHandler.ashx?&Src={0}&ImgId={1}&CallingSource={2}&maxHeight={3}&maxWidth={4}", "HWDetails", dsPartPhotos.Tables[IMAGES].Rows[i]["HWDetailsID"].ToString(), "EnlargedImage", Session["ImageWidth"], Session["ImageHeight"]);
                if (i == 0)
                {
                    ImageRightPane.ImageUrl = imageURL;
                    ImageRightPane.ToolTip = ImageRightPane.ImageUrl;
                }
                imageSrc = ResolveClientUrl(imageURL);

                oPanel.ID = "Panel" + i.ToString();

                //Change the currently clicked panel border color to blue
                oPanel.Attributes.Add("onclick", "javascript:ctl00_ContentPlaceHolder1_" + oPanel.ClientID + ".className='MouseOverBorderStyle';" + ImageRightPane.ClientID + ".src='" + imageSrc + "'");
                oPanel.Attributes.Add("onclick", "SetValue('" + "ctl00_ContentPlaceHolder1_" + oPanel.ClientID + "', " + "'" + dsPartPhotos.Tables[IMAGES].Rows[i]["HWDetailsID"].ToString() + "', " + "'" + dsPartPhotos.Tables[IMAGES].Rows[i]["PhotoFileName"].ToString() + "');" + ImageRightPane.ClientID + ".src='" + imageSrc + "'");

                oImage.ImageUrl = string.Format("~/PicHandler.ashx?Src={0}&ImgId={1}&CallingSource={2}&maxHeight={3}&maxWidth={4}", "HWDetails", dsPartPhotos.Tables[IMAGES].Rows[i]["HWDetailsID"].ToString(), "ThumbnailSize", 95, 95);
                if (i == 0)
                {
                    oPanel.CssClass = "MouseOverBorderStyle";
                }
                oPanel.Controls.Add(oImage);
                this.DivPhotoList.Controls.Add(oPanel);
            }

        }
ASKER CERTIFIED SOLUTION
Avatar of GlobaLevel
GlobaLevelFlag of United States of America imageProgrammer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers