Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

placeholder not showing up

Status
Not open for further replies.

ChewDoggie

Programmer
Mar 14, 2005
604
US
Hi Fellow programmers!

I'm deploying a .NET web application (my first). My code-behind file is reading a directory of images (jpg files), grabbing the file names and then displaying the images in a placeholder on the aspx page.

This works like a charm in my local development environment but when I deploy the application out to the production server, the images don't show up. Hard coded images do, but not dynamically loaded images.

I noticed when I was reading the files, that they ALL had fully qualified names, such as "C:\Folder1\Folder2\fileName1.jpg", so I have to remove the "C:\Folder1\Folder2" from the string before I do anything with it. Trouble is, I don't know what the fully qualified names look like on the production server, I don't know what to "replace".

I "THINK" this is the problem but don't know for sure. I'm trying to display a fully qualified name on a web page to find out what it says but I can't seem to get it running.

Any help would be appreciated.



AMACycle

American Motorcyclist Association
 
AMACycle: Give the Server.MapPath path a try, e.g.,

strPath = Server.MapPath("Folder1\Folder2\fileName.jpg;"))

Sometimes, if the folders are embedded further into the root of the server you might see something like:

strPath = Server.MapPath(".\Folder1\Folder2\fileName.jpg;"))

..or even..

strPath = Server.MapPath("..\Folder1\Folder2\fileName.jpg;"))

..where one or two dots are used. One of these should solve the problem.
 
AMACycle: I extracted the code from an aspx page and it has an extra parenthesis ")" on the end, obvisouly only two are needed in this case.
 
Thanks, Isadore!

I'm familiar with Server.MapPath from my experience with VB6, but when I try to use it in my Visual Studio IDE, "Server.MapPath" isn't recognized by the system. Is there a class I should be Importing to use this method?

Thanks again!



AMACycle

American Motorcyclist Association
 
AMA: Interesting result you're getting. I have the following in the Page declaration:

In many of my aspx pages I call for jpegs, and usually what I use is simple:

".\Photos\PhotoA.jpeg"

..and so I do not use Server.MapPath at all, nor do I use the complete string for the path, just the above.

Do you get an image 'tag' resident on the rendered page? If so right click on it to see the properties and see what's there. If not check one of the other images that are dynamically produced and see what the path looks like.

Post back and we can do a little research on the web to see if we can't nail this.
 
Actually, I just figured out the path. After the page was loaded, I did a "view source" and found the path by looking at the img src attribute. That got me where I wanted. All of the images are showing up now.

THanks!



AMACycle

American Motorcyclist Association
 
Good. I was going to stick my page declarations in but saw nothing unusual; hence the residual statement above.

Yes, checking the path via the image tab, source, etc is a great way to see what is going on. Also, if there exists an image tag, then you know for certain it is the path that is the problem. Glad you knocked it out - its always the small stuff that drives one a bit crazy -- most of the time at least. Later AMA.
 
its always the small stuff that drives one a bit crazy"....you can say that again. The learning curve for .NET is a bit much and it sometimes takes me hours to figure out how to do something in .NET that'd take me minutes to do in another language. But, I suppose it'll all become familiar to me, in time.

THanks for helping on a Sunday morning.



AMACycle

American Motorcyclist Association
 
I just figured out that "MapPath" thing...

Dim idir As String = "imgs/"
Dim adir As String = idir & "aggie/"
Dim MyFiles As String() = Directory.GetFiles(Server.MapPath(adir))



AMACycle

American Motorcyclist Association
 
AMA - one more small note. In the first place, don't hesitage to drop by Tek-Tips - there are some very sharp people here who are more than happy to help - I hardly doubt you can wear our your welcome here; the only rule seems to be "keep it academic".

I would try and keep down your objects, such as creating two strings above, better perhaps to write:

Dim adir As String = "imgs/agggie/"

Here's the issue. One of the biggest problems that I have ever read about with dot NET is "memory leakage". This results from a whole host of events, most notably the creation of objects that are not flushed, cleared, closed, set to Nothing, etc, etc. In addition this goes a bit deeper than this; beyond my expertise. You may consider doing some reading up in this area if this is going to be a part of your carrer -- I have read several briefs on the subject and it has been declared by many of these writers to be one of the deepest traps in scaling up a web site, etc.

So, avoid variables when you can, avoid Session when you can, and make sure all objects (readers, connections, etc) are closed and cleared out as much as possible.

I am not a professional programnmer so have limited knowledge in this area -- take it from me though that this goes even deeper than I have explained -- there are several aspects to this "memory leakage" business that I do not understand -- just a heads up AMA --

And don't make yourself a stranger around here; what makes Tek-Tips such a great site to come to is that nearly everyone here is generous with their time, and pretty darn bright I must say. Of course there are other discussion forums etc and one should reach out and use a collective array of them -- I have been coming to Tek-Tips for around 3 years + now and I am always impressed.

For example (I always love to use this example) -- when you go over to the Javascript forum for some reason -- it is amazing how fast those guys/gals jump on an issue -- and they are not shy about it either -- it is the truth that half the time I post a java question they nail me on some technicality of which I have overlooked (but should not have) - so now I approach it with a deeper sense of what it is I am doing - and so in the end a great learning experience. Glad to help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top