dynamic table content?

R

Rudi Ahlers

If I have a site layout, with a banner on top, menu on the left, and some
nice borders all around, and I want to change the content of the middle
cell, what is the best way of doing it?

As example:

<TABLE border=0 width=98%>
<tr colspan=3>
<td> Header stuff goed here </td>
</tr>
<tr>
<td> Menu stuff goes hers </td>
</tr>
<tr>
<td> Main website content goes here </td>
</tr>
</table>


Now, I have say default.asp, and the menu buttons would point to
default.asp?page=home / default.asp?page=contact / etc

How do I change the main website content?

I tried the following, but this doesn't seem to work:

<%

pagename = request.quesrystring("page")

select case pagename
case "home" iPage = "home.asp"
case "contact" iPage = "contact.asp"
end select


%>


<TABLE border=0 width=98%>
<tr colspan=3>
<td> Header stuff goed here </td>
</tr>
<tr>
<td> Menu stuff goes hers </td>
</tr>
<tr>
<td> <!--#include file=<%=iPage %<--> </td>
</tr>
</table>


response.write(iPage) displays home.asp if I have default.asp?page=home

any help on this would be greatly appreciated :)


--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
 
S

Steven Burn

Querystring + Select Case (or If/Then)

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
R

Rudi Ahlers

Ok, this won't work for me, as my list of links is rather long.Isn't there a
better way of doing it?
In PHP it's rather easy to simply include a file, but it seems like this is
a limit in ASP, and I'm sure there has to be a way around designing each
page from scratch. What happens if you want to update the menu? Go through
100-odd files and change it? Doesn't sound logic to me

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
Rudi Ahlers said:
If I have a site layout, with a banner on top, menu on the left, and some
nice borders all around, and I want to change the content of the middle
cell, what is the best way of doing it?

As example:

<TABLE border=0 width=98%>
<tr colspan=3>
<td> Header stuff goed here </td>
</tr>
<tr>
<td> Menu stuff goes hers </td>
</tr>
<tr>
<td> Main website content goes here </td>
</tr>
</table>


Now, I have say default.asp, and the menu buttons would point to
default.asp?page=home / default.asp?page=contact / etc

How do I change the main website content?

I tried the following, but this doesn't seem to work:

<%

pagename = request.quesrystring("page")

select case pagename
case "home" iPage = "home.asp"
case "contact" iPage = "contact.asp"
end select


%>


<TABLE border=0 width=98%>
<tr colspan=3>
<td> Header stuff goed here </td>
</tr>
<tr>
<td> Menu stuff goes hers </td>
</tr>
<tr>
<td> <!--#include file=<%=iPage %<--> </td>
</tr>
</table>

You can't do that. Server Side Includes happen BEFORE any ASP processing
takes place. This artcile may help:
http://www.aspfaq.com/show.asp?id=2042

Regards,
Peter Foti
 
B

Bob Barrows [MVP]

I suppose you could open the specified file using fso and response.write its
contents:

<%
dim sHTML
CONST ForReading = 1
pagename = request.quesrystring("page")

select case pagename
case "home" iPage = "home.asp"
case "contact" iPage = "contact.asp"
end select
iPage = server.mappath(iPage)
set fso=server.createobject("scripting.filesystemobject")
file= fso_OpenTextFile(iPage , ForReading, true)
sHTML = server.htmlencode(file.readall)
file.close:set file=nothing

%>
....
<td> <%=sHTML%></td>


HTH,
Bob Barrows
 
B

Bob Barrows [MVP]

Bob said:
I suppose you could open the specified file using fso and
response.write its contents:

<%
dim sHTML
CONST ForReading = 1
pagename = request.quesrystring("page")

select case pagename
case "home" iPage = "home.asp"
case "contact" iPage = "contact.asp"
end select
iPage = server.mappath(iPage)
set fso=server.createobject("scripting.filesystemobject")
file= fso_OpenTextFile(iPage , ForReading, true)

set file= fso_OpenTextFile(iPage , ForReading, true)
 
R

Rudi Ahlers

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
Bob said:
I suppose you could open the specified file using fso and
response.write its contents:

<%
dim sHTML
CONST ForReading = 1
pagename = request.quesrystring("page")

select case pagename
case "home" iPage = "home.asp"
case "contact" iPage = "contact.asp"
end select
iPage = server.mappath(iPage)
set fso=server.createobject("scripting.filesystemobject")
file= fso_OpenTextFile(iPage , ForReading, true)

set file= fso_OpenTextFile(iPage , ForReading, true)



--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Peter, I read the link you send me, and from that I got this to work:



<%
pagename = request.QueryString("page")
%>
<TABLE WIDTH="90%" BORDER="1" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD><%=Server.Execute(pagename & ".asp")%></TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>


The other option, with it being in the if/else loop is not viable though,
it's prone to bring in some errors. Thanx for the link though, the link on
the bottom of that page made me use this feature. It's easy to use, and easy
to maintain.

Bob, how would fso work with .asp pages, that contains serverside code?
 
B

Bob Barrows [MVP]

Rudi said:
Bob, how would fso work with .asp pages, that contains serverside code?

Not well. This would only work for writing text/html to the response.

Bob Barrows
 

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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top