|
 |
asp_web_howto thread: dynamic path for include file
Message #1 by Roger Balliger <Roger@i...> on Fri, 29 Dec 2000 06:17:34 -0800
|
|
Here's what I'm trying to do:
I have a table. The top cell is a header, the side is a nav, and the center
is the content cell. I use server side include files to bring in styles,
navs and content. What I need to do is be able to use a variable in the
path of the include file. For example, '<!-- #include
virtual="/intratnet/manual/pages/<%=PageCheck%>xxcn.htm" -->'. You can see
that the variable PageCheck is the first part of the file name which I would
like to change to bring in different content as needed. One way this
variable could be changed is by the user selecting a new item from a combo
box where the value is equal to the variable part of the filename. I only
want to chage the contents of one cell dynamically by using a include file
which is dynamic. Can this be done? If not, what are some other options?
What I have tried:
I am connecting to a dbase. I tried to list the path in a dbase field and
bring it in as a value. This caused errors with the label of the combo box
and was to long to be recognized by ASP.
I tried storing the include path in a variable and using response.write to
display it but the include command name was not processed as ASP since it
was written after the ASP was processed. If the ASP processor were to make
2 passes over the code, then it would be caught, but ASP doesn't work that
way.
I am contemplating using frames and storing the path for the new source cell
in a dbase field and then storing that as a value for the combo box to be
used as the new frame source when an item is selected.
Any suggestions will be greatly appreciated. I know there must be an
efficient way to change content in a cell based on user selections without
using frames. Amazon and search engines do this.
Thanks for any help.
Roger Balliger
---
MaximumASP offers enhanced hosting solutions on the Windows 2000 platform. Dedicated processor, RAM, and server resources provide
dedicated server performance at virtual server prices. Commercial components provided; custom components allowed.
---
You are currently subscribed to asp_web_howto as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-asp_web_howto-$subst('Recip.MemberIDChar')@p2p.wrox.com
Message #2 by Vladimir Valdivia Galvan <vvaldivia@t...> on Fri, 29 Dec 2000 09:53:31 -0500
|
|
Hi,
First of all, you must know that "#include" is processed BEFORE ASP, so you
can not include a file dinamically. The only way to do this is including N
files and with an "If statement" show the result to the user:
<% If var_a = "1" Then %>
<!-- #include... >
<% Else If %>
<!-- #include... >
<% End If %>
...but this does not work when you have to include many files... so the
second option is to include the file you want (html in your case) with a
FileSystem Object... so you just "read" thye file and show the contents:
<%
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
path = Server.MapPath("/") 'this returns the path of your web site
path = path & "\folder_name\" & file_name & ".html""
'shows the file
If fso.FileExists(path) Then
Set ThisFile = fso.OpenTextFile(path_aviso,1,FALSE,FALSE)
Do While ThisFile.AtEndOfStream <> True
Response.Write (UCase(ThisFile.ReadLine) & "<br>" & Chr(13)
& Chr(10))
Loop
ThisFile.close
Set ThisFile = Nothing
Else
'the file does not exist!
End If
Set fso = Nothing
%>
Hope that helps,
Happy Holydays!
Vladimir Valdivia
http://amarillastelefonica.com
-----Mensaje original-----
De: Roger Balliger [mailto:Roger@i...]
Enviado el: viernes 29 de diciembre de 2000 9:18
Para: ASP Web HowTo
Asunto: [asp_web_howto] dynamic path for include file
Here's what I'm trying to do:
I have a table. The top cell is a header, the side is a nav, and the center
is the content cell. I use server side include files to bring in styles,
navs and content. What I need to do is be able to use a variable in the
path of the include file. For example, '<!-- #include
virtual="/intratnet/manual/pages/<%=PageCheck%>xxcn.htm" -->'. You can see
that the variable PageCheck is the first part of the file name which I would
like to change to bring in different content as needed. One way this
variable could be changed is by the user selecting a new item from a combo
box where the value is equal to the variable part of the filename. I only
want to chage the contents of one cell dynamically by using a include file
which is dynamic. Can this be done? If not, what are some other options?
What I have tried:
I am connecting to a dbase. I tried to list the path in a dbase field and
bring it in as a value. This caused errors with the label of the combo box
and was to long to be recognized by ASP.
I tried storing the include path in a variable and using response.write to
display it but the include command name was not processed as ASP since it
was written after the ASP was processed. If the ASP processor were to make
2 passes over the code, then it would be caught, but ASP doesn't work that
way.
I am contemplating using frames and storing the path for the new source cell
in a dbase field and then storing that as a value for the combo box to be
used as the new frame source when an item is selected.
Any suggestions will be greatly appreciated. I know there must be an
efficient way to change content in a cell based on user selections without
using frames. Amazon and search engines do this.
Thanks for any help.
Roger Balliger
---
MaximumASP offers enhanced hosting solutions on the Windows 2000 platform. Dedicated processor, RAM, and server resources provide
dedicated server performance at virtual server prices. Commercial components provided; custom components allowed.
---
You are currently subscribed to asp_web_howto as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-asp_web_howto-$subst('Recip.MemberIDChar')@p2p.wrox.com
Message #3 by Roger Balliger <Roger@i...> on Fri, 29 Dec 2000 08:32:34 -0800
|
|
Thanks. I'll give it a try.
In the mean time, I'm assuming the variable 'file_name' will be my variable
who's value I can change to modify the path name of the file I want to open.
Also, are you sure this will work to display the file contents within a
table cell (just as an include file would)?
Thanks again Vladimir.
Roger
-----Original Message-----
From: Vladimir Valdivia Galvan
To: ASP Web HowTo
Sent: 12/29/00 6:53 AM
Subject: [asp_web_howto] RE: dynamic path for include file
Hi,
First of all, you must know that "#include" is processed BEFORE ASP, so
you
can not include a file dinamically. The only way to do this is including
N
files and with an "If statement" show the result to the user:
<% If var_a = "1" Then %>
<!-- #include... >
<% Else If %>
<!-- #include... >
<% End If %>
...but this does not work when you have to include many files... so the
second option is to include the file you want (html in your case) with a
FileSystem Object... so you just "read" thye file and show the contents:
<%
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
path = Server.MapPath("/") 'this returns the path of your web site
path = path & "\folder_name\" & file_name & ".html""
'shows the file
If fso.FileExists(path) Then
Set ThisFile = fso.OpenTextFile(path_aviso,1,FALSE,FALSE)
Do While ThisFile.AtEndOfStream <> True
Response.Write (UCase(ThisFile.ReadLine) & "<br>" &
Chr(13)
& Chr(10))
Loop
ThisFile.close
Set ThisFile = Nothing
Else
'the file does not exist!
End If
Set fso = Nothing
%>
Hope that helps,
Happy Holydays!
Vladimir Valdivia
http://amarillastelefonica.com
-----Mensaje original-----
De: Roger Balliger [mailto:Roger@i...]
Enviado el: viernes 29 de diciembre de 2000 9:18
Para: ASP Web HowTo
Asunto: [asp_web_howto] dynamic path for include file
Here's what I'm trying to do:
I have a table. The top cell is a header, the side is a nav, and the
center
is the content cell. I use server side include files to bring in
styles,
navs and content. What I need to do is be able to use a variable in the
path of the include file. For example, '<!-- #include
virtual="/intratnet/manual/pages/<%=PageCheck%>xxcn.htm" -->'. You can
see
that the variable PageCheck is the first part of the file name which I
would
like to change to bring in different content as needed. One way this
variable could be changed is by the user selecting a new item from a
combo
box where the value is equal to the variable part of the filename. I
only
want to chage the contents of one cell dynamically by using a include
file
which is dynamic. Can this be done? If not, what are some other
options?
What I have tried:
I am connecting to a dbase. I tried to list the path in a dbase field
and
bring it in as a value. This caused errors with the label of the combo
box
and was to long to be recognized by ASP.
I tried storing the include path in a variable and using response.write
to
display it but the include command name was not processed as ASP since
it
was written after the ASP was processed. If the ASP processor were to
make
2 passes over the code, then it would be caught, but ASP doesn't work
that
way.
I am contemplating using frames and storing the path for the new source
cell
in a dbase field and then storing that as a value for the combo box to
be
used as the new frame source when an item is selected.
Any suggestions will be greatly appreciated. I know there must be an
efficient way to change content in a cell based on user selections
without
using frames. Amazon and search engines do this.
Thanks for any help.
Roger Balliger
---
MaximumASP offers enhanced hosting solutions on the Windows 2000 platform. Dedicated processor, RAM, and server resources provide
dedicated server performance at virtual server prices. Commercial components provided; custom components allowed.
---
You are currently subscribed to asp_web_howto as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-asp_web_howto-$subst('Recip.MemberIDChar')@p2p.wrox.com
Message #4 by "TomMallard" <mallard@s...> on Fri, 29 Dec 2000 08:16:35 -0800
|
|
Consider using the database as the repository for the actual content instead
of the path. A batch tool coded in asp can open all the files in a folder
and add them as table entries to create this library. This gives you the
actual content delivered by the database to the page instead of using the
file system. Also, the content is easier to update, roll-back, etc. because
it's in a db.
A hassle with doing this for html or coding is converting the special
characters when adding content to the db, you need a conversion subroutine.
Other than that, I find it an easy way to get the functionality of dynamic
includes and better control over the content.
tom mallard
seattle
----- Original Message -----
From: "Roger Balliger" <Roger@i...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Friday, December 29, 2000 6:17 AM
Subject: [asp_web_howto] dynamic path for include file
| Here's what I'm trying to do:
|
| I have a table. The top cell is a header, the side is a nav, and the
center
| is the content cell. I use server side include files to bring in styles,
| navs and content. What I need to do is be able to use a variable in the
| path of the include file. For example, '<!-- #include
| virtual="/intratnet/manual/pages/<%=PageCheck%>xxcn.htm" -->'. You can
see
| that the variable PageCheck is the first part of the file name which I
would
| like to change to bring in different content as needed. One way this
| variable could be changed is by the user selecting a new item from a combo
| box where the value is equal to the variable part of the filename. I only
| want to chage the contents of one cell dynamically by using a include file
| which is dynamic. Can this be done? If not, what are some other options?
|
| What I have tried:
|
| I am connecting to a dbase. I tried to list the path in a dbase field and
| bring it in as a value. This caused errors with the label of the combo
box
| and was to long to be recognized by ASP.
| I tried storing the include path in a variable and using response.write to
| display it but the include command name was not processed as ASP since it
| was written after the ASP was processed. If the ASP processor were to
make
| 2 passes over the code, then it would be caught, but ASP doesn't work that
| way.
|
| I am contemplating using frames and storing the path for the new source
cell
| in a dbase field and then storing that as a value for the combo box to be
| used as the new frame source when an item is selected.
|
| Any suggestions will be greatly appreciated. I know there must be an
| efficient way to change content in a cell based on user selections without
| using frames. Amazon and search engines do this.
|
| Thanks for any help.
|
| Roger Balliger
|
---
MaximumASP offers enhanced hosting solutions on the Windows 2000 platform. Dedicated processor, RAM, and server resources provide
dedicated server performance at virtual server prices. Commercial components provided; custom components allowed.
---
You are currently subscribed to asp_web_howto as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-asp_web_howto-$subst('Recip.MemberIDChar')@p2p.wrox.com
Message #5 by Roger Balliger <Roger@i...> on Fri, 29 Dec 2000 12:06:04 -0800
|
|
That is a great idea. I think the content woould be too large though. Each
content file is approximately the size a 2-page word doc (converted to HTML)
with table formatting and XML (thanks to Word2K). Do you think it would
still work? Or even be worth trying? I'm thinking the fileSystemObject may
be the best route.
-----Original Message-----
From: TomMallard
To: ASP Web HowTo
Sent: 12/29/00 8:16 AM
Subject: [asp_web_howto] Re: dynamic path for include file
Consider using the database as the repository for the actual content
instead
of the path. A batch tool coded in asp can open all the files in a
folder
and add them as table entries to create this library. This gives you the
actual content delivered by the database to the page instead of using
the
file system. Also, the content is easier to update, roll-back, etc.
because
it's in a db.
A hassle with doing this for html or coding is converting the special
characters when adding content to the db, you need a conversion
subroutine.
Other than that, I find it an easy way to get the functionality of
dynamic
includes and better control over the content.
tom mallard
seattle
----- Original Message -----
From: "Roger Balliger" <Roger@i...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Friday, December 29, 2000 6:17 AM
Subject: [asp_web_howto] dynamic path for include file
| Here's what I'm trying to do:
|
| I have a table. The top cell is a header, the side is a nav, and the
center
| is the content cell. I use server side include files to bring in
styles,
| navs and content. What I need to do is be able to use a variable in
the
| path of the include file. For example, '<!-- #include
| virtual="/intratnet/manual/pages/<%=PageCheck%>xxcn.htm" -->'. You
can
see
| that the variable PageCheck is the first part of the file name which I
would
| like to change to bring in different content as needed. One way this
| variable could be changed is by the user selecting a new item from a
combo
| box where the value is equal to the variable part of the filename. I
only
| want to chage the contents of one cell dynamically by using a include
file
| which is dynamic. Can this be done? If not, what are some other
options?
|
| What I have tried:
|
| I am connecting to a dbase. I tried to list the path in a dbase field
and
| bring it in as a value. This caused errors with the label of the
combo
box
| and was to long to be recognized by ASP.
| I tried storing the include path in a variable and using
response.write to
| display it but the include command name was not processed as ASP since
it
| was written after the ASP was processed. If the ASP processor were to
make
| 2 passes over the code, then it would be caught, but ASP doesn't work
that
| way.
|
| I am contemplating using frames and storing the path for the new
source
cell
| in a dbase field and then storing that as a value for the combo box to
be
| used as the new frame source when an item is selected.
|
| Any suggestions will be greatly appreciated. I know there must be an
| efficient way to change content in a cell based on user selections
without
| using frames. Amazon and search engines do this.
|
| Thanks for any help.
|
| Roger Balliger
|
---
MaximumASP offers enhanced hosting solutions on the Windows 2000 platform. Dedicated processor, RAM, and server resources provide
dedicated server performance at virtual server prices. Commercial components provided; custom components allowed.
---
You are currently subscribed to asp_web_howto as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-asp_web_howto-$subst('Recip.MemberIDChar')@p2p.wrox.com
Message #6 by "TomMallard" <mallard@s...> on Fri, 29 Dec 2000 13:00:29 -0800
|
|
Short answer is yes, just like an include. But.
Forgot about ASP3.0 having dealt with this, you can use the server.execute
method instead for each if condition ...if (?) then
server.execute("file_name")... That would give you another way to do it
dynamically without having to convert the files so is a better idea.
I just like using the database for include type global coding snippets,
functions and whatever. In a dev environment this puts the include library
into a database where you can actually find something by searching the
content yourself with query analyzer.
Anyway, if this appeals, what you do is create an asp page that opens the
existing include files, copies them as a string which is \'parsed for
special characters\' (single quotes etc. need a backslash) into varchars.
This converts the actual file into a field in a database table where the key
field name is your unique "file_name" and this second field with the actual
contents.
When you need that include, you run a query with a where clause and the
recordset object ...rsInput("file_contents")... returns what was formerly in
a file and then you response.write it where you need it. If these are bigger
than 8,000 you have to parse them into packages and concatenate them back so
that's when I would use server.execute for sure.
tom mallard
seattle
----- Original Message -----
From: "Roger Balliger" <Roger@i...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Friday, December 29, 2000 8:32 AM
Subject: [asp_web_howto] RE: dynamic path for include file
| Thanks. I'll give it a try.
|
| In the mean time, I'm assuming the variable 'file_name' will be my
variable
| who's value I can change to modify the path name of the file I want to
open.
|
| Also, are you sure this will work to display the file contents within a
| table cell (just as an include file would)?
|
| Thanks again Vladimir.
| Roger
|
| -----Original Message-----
| From: Vladimir Valdivia Galvan
| To: ASP Web HowTo
| Sent: 12/29/00 6:53 AM
| Subject: [asp_web_howto] RE: dynamic path for include file
|
| Hi,
| First of all, you must know that "#include" is processed BEFORE ASP, so
| you
| can not include a file dinamically. The only way to do this is including
| N
| files and with an "If statement" show the result to the user:
|
| <% If var_a = "1" Then %>
| <!-- #include... >
| <% Else If %>
| <!-- #include... >
| <% End If %>
|
| ...but this does not work when you have to include many files... so the
| second option is to include the file you want (html in your case) with a
| FileSystem Object... so you just "read" thye file and show the contents:
|
| <%
| Dim fso
| Set fso = CreateObject("Scripting.FileSystemObject")
| path = Server.MapPath("/") 'this returns the path of your web site
| path = path & "\folder_name\" & file_name & ".html""
|
| 'shows the file
| If fso.FileExists(path) Then
| Set ThisFile = fso.OpenTextFile(path_aviso,1,FALSE,FALSE)
| Do While ThisFile.AtEndOfStream <> True
| Response.Write (UCase(ThisFile.ReadLine) & "<br>" &
| Chr(13)
| & Chr(10))
| Loop
| ThisFile.close
| Set ThisFile = Nothing
| Else
| 'the file does not exist!
| End If
|
| Set fso = Nothing
| %>
|
|
| Hope that helps,
| Happy Holydays!
| Vladimir Valdivia
| http://amarillastelefonica.com
|
|
|
| -----Mensaje original-----
| De: Roger Balliger [mailto:Roger@i...]
| Enviado el: viernes 29 de diciembre de 2000 9:18
| Para: ASP Web HowTo
| Asunto: [asp_web_howto] dynamic path for include file
|
| Here's what I'm trying to do:
|
| I have a table. The top cell is a header, the side is a nav, and the
| center
| is the content cell. I use server side include files to bring in
| styles,
| navs and content. What I need to do is be able to use a variable in the
| path of the include file. For example, '<!-- #include
| virtual="/intratnet/manual/pages/<%=PageCheck%>xxcn.htm" -->'. You can
| see
| that the variable PageCheck is the first part of the file name which I
| would
| like to change to bring in different content as needed. One way this
| variable could be changed is by the user selecting a new item from a
| combo
| box where the value is equal to the variable part of the filename. I
| only
| want to chage the contents of one cell dynamically by using a include
| file
| which is dynamic. Can this be done? If not, what are some other
| options?
|
| What I have tried:
|
| I am connecting to a dbase. I tried to list the path in a dbase field
| and
| bring it in as a value. This caused errors with the label of the combo
| box
| and was to long to be recognized by ASP.
| I tried storing the include path in a variable and using response.write
| to
| display it but the include command name was not processed as ASP since
| it
| was written after the ASP was processed. If the ASP processor were to
| make
| 2 passes over the code, then it would be caught, but ASP doesn't work
| that
| way.
|
| I am contemplating using frames and storing the path for the new source
| cell
| in a dbase field and then storing that as a value for the combo box to
| be
| used as the new frame source when an item is selected.
|
| Any suggestions will be greatly appreciated. I know there must be an
| efficient way to change content in a cell based on user selections
| without
| using frames. Amazon and search engines do this.
|
| Thanks for any help.
|
| Roger Balliger
|
|
|
---
MaximumASP offers enhanced hosting solutions on the Windows 2000 platform. Dedicated processor, RAM, and server resources provide
dedicated server performance at virtual server prices. Commercial components provided; custom components allowed.
---
You are currently subscribed to asp_web_howto as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-asp_web_howto-$subst('Recip.MemberIDChar')@p2p.wrox.com
|
|
 |