Questions

Concerning Serverside Include in ASP

+
0 Votes
Locked

Concerning Serverside Include in ASP

jdardard
For some unknown reason, (ASP)serverside include will not find graphics or images even though the file is in the same location as the site. All is fine when I only have text in the files, but for images or graphics, I only get a question mark (?)where the image or graphic should be. The file(s) in question are in a folder of the same site, so there's no need to search distant files. I get the same results whether I use "file" or "virtual." Occasionally, I will get a page full of different characters for pictures and/or graphics instead of the question mark. Any assistance will be greatly appreciated.

Thanks very much,

Joe Dardard
+
0 Votes
TobiF
Collapse -

It's easier for people to help if you give an example of what you have written that doesn't work.

An include usually means that the referred file is directly injected into th stream. If you inject almost random binary data (Have a look at a jpg file in Notepad, and you'll agree) into an html (text) stream, then something WILL go wrong.

If you want to place a picture in a web page, then you need to write something, that will at the end send the correctly formatted IMG-tag to the user's browser.

EditAdd: Oh. You may want to delete your email address from your post before too many robots picks it up and start spamming.

+
0 Votes
jdardard
Collapse -

Thanks for your quick reply, TobiF. First, I should emphasize that I'm using Dreamweaver CS4, which handles ASP nicely. As long as I use the Serverside Include to include the text from a stored file (stored in my inc file), all is well. I have numerous samples from old school books that work fine. However, when I try to emulate those examples, using the very same format, with photos or graphics in various formats (jpeg, gif, etc., I either get nothing, or I get a screen full of various characters. I've tried creating my inc files in .asp, .html, and .txt, all of which are supposed to work, since the serverside include is supposed to accept them all. Doesn't matter, though. Still doesn't work. So, I can only conclude that somewhere, there's a code problem, but where seems to be beyond me. Being that I suspect a code problem, I'm not sure how much help I can get on this forum. I'm usually very good at code writing. Somewhere, though,there's a hangup, and that's what I'm trying to find.

Thanks again,

Joe Dardard

+
0 Votes
brian
Collapse -

if i am following correctly, you are building this site in asp, you have all your code and pics located in the same folder, have you tried adding an images folder the root level of the site and pointing the "img src=../images/imagename.ext?" this is how i code my sites and rarely have a problem, but then again, my luck seems to be strange in code....just as a fun note, CTRL+SHIFT+B will not submit the post like i have now pressed 3 times instead of clicking submit post lol

+
0 Votes
jdardard
Collapse -

Hi Brian,

I have not tried that, but it's certainly worth a try. The problem is not as serious as I make it sound, because none of my sites are very large and the need for serverside includes is not crucial. But being relatively new to ASP, I want to smooth out all the bugs I run into. Who knows, next month, or next year, I may be working on larger sites and would need serverside includes. But I will try your suggestion. It certainly can't hurt anything.

Thanks millions,

Joe Dardard

+
0 Votes
brian
Collapse -

Joe,
I'm relativly new at programing in ASP as well, however the sites i build are rather detailed and large (internal company employee sites connected to sql db's and the such). I have found this to be the most useful when i have a root directory as i call it of website1 with 40 different subsites in it...i can place all of the images in the images folder and no matter what site i use (as long as it isn't created in a new folder), i can access any picture i want (may i recommned using jpg's, and if you are creating your own use fireworks to create them as you can mostly control the size) just by putting in the img src, ../images/imagenamehere.ext. By doing this as well i don't have to place duplicate images in every time, and as said by Tobi *sorry if that isn't correct its curretnly 2:30ish am* if you are using the include method to embed the pic into the webpage, you will get gibberish. If you are serious about programing is ASP, may i recommend looking into visual studio to write it all in, and just using dreamweaver as a program to design your basic layout with "dummy fields" like PICTURE1HERE or TEXTBOXHERE...etc. you can copy the info btwn the dreamweaver body tags and place it btwn the div tags in visual studio.

+
0 Votes
jdardard
Collapse -

Hi Brian,

I do have visual studio. I think, in fact, I know I will be able to get better results with it than in Dreamweaver, which is nice, but it does have some drawbacks when developing dynamic sites. Perhaps, it's because I'm not that familiar with it, but I like the idea of using visual studio much better. Thanks so much for the hint -- and the solution. You've been most helpful... Good luck in your endeavor...

Joe Dardard

+
0 Votes
brian
Collapse -

Anytime, good luck with your endeavor as well...if you need any help, though i am fairly new, let me know i'd be glad to answer anything i can for you.

+
0 Votes
TobiF
Collapse -

You just INClude the jpg (or whatever) right into the html text of the page.
That will only give you garbish.

Instead, you need to place file with the picture somewhere, where the browser can find it. Then you include the picture in your page by a certain html tag:
{img src="filename.jpg"} (replace {} with less than/greater) if the image file is in the same catalog as the asp file.

You may also use relative addressing, like you see in the reply from Brian.

If the images are on a different site, then you need to use the full URL in the SRC-parameter, like this: "http://somesite.com/directory/filename.jpg "

I haven't worked with dreamweaver, but there should be some other button to click when you want to insert an image. (Include does NOT help, as you've seen.)

+
0 Votes
jdardard
Collapse -

Hi Tobi,

Thanks again for the info. I think your suggestion will work, but I'm going to try using Visual Studio instead of Dreamweaver CS4 as suggested by Brian. Being relatively new to programming, every little hint helps, but as I get used to visual studio, I'm getting to like it more and more. However, you've been very helpful, and I do appreciate you taking the time to respond to my question. Thanks again, and do have a wonderful day.

Joe Dardard

+
0 Votes
TobiF
Collapse -

You're welcome.
I'm sure both VS and DV are much more versatile than notepad :) So good luck!