Using Same Template In All ASP Pages

R

rn5a

Please have a look at the image at the URL given below:

http://rn5a.brinkster.net/Template.gif

I would like to use that image as a template for all the ASP pages in
a website. Note that though it looks like a frames page, it's actually
not a frames page. Using different images has made it look like a
frames page.

The "Your Site Name" header, the 5 links "Home", "About", "Forums",
"Downloads" & "Support" links & the different links on the left hand
side will be available in all the pages. In other words, the actual
contents of the different pages would be displayed where there's "TEXT
COMES HERE".

I am not very sure on how to go about it. Can someone please give some
idea?

What I was thinking of doing is encapsulating the entire template in
an INCLUDE file, say, Template.inc & then adding the following code in
Template.inc (note that the template not only uses images but also
HTML tables)

<%
Sub SetTemplate(strTitle,strBody)
'here comes the upper part of the template
'wherever the <title> tags come, I will use the variable
strTitle
%>
<title><%= strTitle %></title>
<%
'here comes the left hand side of the template

'finally here comes the contents of the files that will use
this template

strBody
%>

For e.g. when the "Forums" link is clicked, users are first told to
login using their username & password. Assume that the page where
users login is named Login.asp. This will be the code in Login.asp:

<!-- #include file="Template.inc" -->

<%
Dim sBody

sBody="<form method=post action='CheckLogin.asp' onSubmit='return
check()'>" & vbCrLf
sBody=sBody & "<input type=text name='username'><br>" & vbCrLf
sBody=sBody & "<input type=password name='password'><br><br>" &
vbCrLf
sBody=sBody & "<input type=submit value='LOGIN'>" & vbCrLf
sBody=sBody & "</form>"

SetTemplate("Please Login",sBody)
%>

Is this the correct approach or can someone suggest me a better
workaround?

Thanks,

RON
 
M

Michael

I would recommend to cut your image into 4( at least parts) . Use Adobe for
example
Each part you can load as background for every page
for 4 parts it can be top part, left part and main part.
create
- top.asp
- left.asp
- main.asp
- footer.asp

make part of your image as background of whole page.
you default page will looks like
include top.asp
include left.asp
include main.asp
include footer.asp

any other page will include
include top.asp
include left.asp
' -----------------
page content
' -----------------
include footer.asp
 
A

Adrienne Boswell

Gazing into my crystal ball I observed (e-mail address removed) writing in
Please have a look at the image at the URL given below:

http://rn5a.brinkster.net/Template.gif

I would like to use that image as a template for all the ASP pages in
a website. Note that though it looks like a frames page, it's actually
not a frames page. Using different images has made it look like a
frames page.

The "Your Site Name" header, the 5 links "Home", "About", "Forums",
"Downloads" & "Support" links & the different links on the left hand
side will be available in all the pages. In other words, the actual
contents of the different pages would be displayed where there's "TEXT
COMES HERE".

I am not very sure on how to go about it. Can someone please give some
idea?

What I was thinking of doing is encapsulating the entire template in
an INCLUDE file, say, Template.inc & then adding the following code in
Template.inc (note that the template not only uses images but also
HTML tables)

Please don't use HTML tables for anything but tabular data. Tables are
not for positioning elements. Please use CSS and don't use
presentational markup.

<% option explicit
thispage = "" 'the page title goes in title and h1 element
thisurl = "" 'the actual url, needed for navigation
%>
<!--#include file="linkrel.asp"-->
<%
'linkrel includes DTD, HTML and Head elements, including the link to the
'stylesheet and favicon. I usually include a file called
'masterfunctions.asp and conn_inc.asp in this file as well.
'The usage of thispage above is like so:
'<title><%=thispage%></title>
%>
</head>
<body>
<!--#include file="header_inc.asp"-->
<!--#include file="nav_inc.asp"-->
<!--#include file="leftlinks_inc.asp"-->
<div id="content">
</div>
<!--#include file="footer_inc.asp"-->
</body>
</html>

-- Nav_inc.asp --
pagearr = array("Home", "About", "Forums", "Downloads", "Support")
hrefarr = array("index.asp", "about.asp", "forum.asp", "downloads.asp",
"support.asp")

%>
<ul>
<li class="skipnav"><a href="#content">Skip Navigation</a></li>
<% for i = 0 to ubound(pagearr)
%>
<li><%=navlist(hrefarr(i),pagearr(i))%></li>
<%
next%>
</ul>

<%
'this function usually goes into the masterfunctions.asp page
function navlist(link,document)
if trim(thisurl) = trim(link) then
navlist = "<a class=" & chr(034) & "thispage" & chr(034) & "
href=" & chr(034)
navlist = navlist & chr(034) & ">" & document & "</a>"
else
navlist = "<a href=" & chr(034)
navlist = navlist & chr(034) & ">" & document & "</a>"
end if
end function
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top