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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add code to every page loaded 1

Status
Not open for further replies.

DanT07

Programmer
May 11, 2005
38
0
0
GB
Hi

Not sure if this is posted in the right category but I wouldnt even know where it should be posted.

I just want to know if there is any way a page can have a header inserted automatically? For example if a user uploads a page I want that page to have a banner at the top without manually editing the file to have an include in.

Is this possible? I know IIS can add a footer but a header would be much better.

Thanks
Dan
 
you can create two asp files one for header(header.asp) and one for footer(footer.asp)

and then in all the remaining pages where you want header and footer you can include both the header.asp and footer.asp files...something like

<!--# include file="header.asp"-->
<!--# include file="footer.asp"-->

-DNG

 
No i meant can you do it without using include code? So a user can upload a page without any extra code in and the banner appears instantly, without modifying the code.

I think perhaps I posted in the wrong category as its probably not possible to do this with ASP.

:-/
 
It sounds like he's looking for something along the lines of what the free webservers use to add advertising to a page. You load your page in, and the server adds the code to the top of the page for the ads. Your best bet is probably to address this in the forum relevant to the server software your host is using.

I remember reading something about this a few years ago, but don't recall what or where right now.

Lee
 
You could always add javascript code to the page footer (via IIS) which in turn adds an onload event and then adds a section of HTML at the top of the BODY section. You could either inject the html directly into the page or float it above the content, with the option for the user to close (hide) it.

Or you could control the upload of content, and manipulate the uploaded file to do an include of your required code at the relevant part. E.g. when the user uploads the file via ASP, modify the content so that an include file is added (either ASP include or SSI).

Or you could have a conduit page which contains your code plus the Server.Execute or FSO functionality to read in the required file where you want it - you can either run Apache with IIS and use mod_rewrite, or custom 404's or querystring parameters to identify the page to be rendered.

They're all messy and horrible, but.. the most reliable will be the second option, but the easiest will be the first.

Finally, probably the cleanest way would be to write your own custom ISAPI filter to do the work, which should also be more efficient, however this is the most technically complex, and it sounds like you would be better taking an easier route.

Hope this helps - but if it were me, I wouldn't do this at all - no-one likes their content to be mangled by forced ads that neither the page creator nor the reader wants to see. Just a thought.

A smile is worth a thousand kind words. So smile, it's easy! :)
 
They're all messy and horrible, but..
[...]
probably the cleanest way would be to write your own custom ISAPI filter

Very good answer.
star.gif
 
Cheers Sheco :)

A smile is worth a thousand kind words. So smile, it's easy! :)
 
Hmm yeah intereseting answer Damber - I think the 2nd option could be a real possibility. That would solve all our problems I think.

Thanks
Ill let you know how it goes, if youre interested that is.
 
Ill let you know how it goes, if youre interested that is.
Sure - post back what you found works so that others can benefit from your experience.

Good luck with it.

A smile is worth a thousand kind words. So smile, it's easy! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top