CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 dinamically include pages

Print topic Send  topic

Author Message
lothar

Posts: 4
Posted: 06/15/2004, 10:50 AM

Is it possible to dinamically include a page?
The name of the page to include is stored in a table that should be filtered by a record ID posted from the previous page.
Does anyone have developed a similar solution?

Thank's a lot and sorry for my bad English.
View profile  Send private message
peterr


Posts: 5971
Posted: 06/15/2004, 11:15 AM

This could be possible in some technologies that support dynamic script inclusion, for example PHP.
However, ASP cannot include scripts dynamically and therefore this may be not possible or could be difficult. At least I don't know of such solution, except copying script files on the disk but this may not work with multiple users.
It could be easier in CCS to include several pages and then hide the ones you don't need.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
GeorgeS

Posts: 206
Posted: 06/19/2004, 6:48 PM

What about using server.execute("page_name.asp")?

_________________
GeorgeS
View profile  Send private message
peterr


Posts: 5971
Posted: 06/19/2004, 10:49 PM

Good point. Although I'm afraid that this could fall into the "difficult" category because I still wouldn't know how to make this work. I think that there are some issues with this approach because executing the whole page is not the same as including a page and then executing methods within that page. However I could be wrong. Sometimes when you attempt to do something it may turn out easier than assumed.
If you've done it successfully feel free to post the solution.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
GeorgeS

Posts: 206
Posted: 06/19/2004, 11:23 PM

I don't have a solution but I hope that someone has.

But I have another thought :
what about creating a New CCS "include" function that uses FileSystemObject to read the content of includable file into the calling asp page?
CCInclude("page.asp") - ?
I'm not sure it would be efficient fast enough though...

_________________
GeorgeS
View profile  Send private message
DonB
Posted: 06/20/2004, 3:27 PM

I don't see how you could do what you are asking. The included object has
to be included via webserver directive, prior to the code being compiled and
therefore before it is executed. So... This is a chicken-and-egg dilemma if
ever I saw one. When you start looking at event handlers, the problem
compounds itself.

One approximation of this general behavior could be to have pages organized
into folders, and the foldername represents the dynamic aspect. So then,
you'd modify the path to a page where you manually insert the foldername
into the Redirect property's parameter (e.g. the URL) before the
Response.Redirect occurs.

Another could be to construct a two-frame <frameset> where one <frame>
dictates what page gets loaded into the other <frame>.

--
DonB

http://www.gotodon.com/ccbth


"GeorgeS" <GeorgeS@forum.codecharge> wrote in message
news:640d52d66f15ab@news.codecharge.com...
> I don't have a solution but I hope that someone has.
>
> But I have another thought :
> what about creating a New CCS "include" function that uses
FileSystemObject to
> read the content of includable file into the calling asp page?
> CCInclude("page.asp") - ?
> I'm not sure it would be efficient fast enough though...
>
> _________________
> GeorgeS
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

GeorgeS

Posts: 206
Posted: 06/20/2004, 7:06 PM

Hi DonB,
thank you for explaining this chicken-and-egg dilemma.
I don't have a lot of experiance with asp and, perhaps, my suggestion was not a good one.
I was trying to experiment with FSO though.
Here is the result:
Main file: 1.asp
**********
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>page: 1.asp</title>
</head>

<body>
<% dim var_pageone
var_pageone="I am page1.asp"
Custom_Include("2.asp")
%>
</body>
</html>

<%
Sub Custom_Include(str_inc)
Dim obj_FSO
Set obj_FSO = Server.CreateObject("Scripting.FileSystemObject")
If obj_FSO.FileExists(Server.MapPath(str_inc)) Then
Set obj_file = obj_FSO.OpenTextFile(Server.MapPath(str_inc), 1)
inc_file = obj_File.ReadAll
inc_file = Replace(inc_file, Chr(60)&Chr(37), "")
inc_file = Replace(inc_file, Chr(37)&Chr(62), "")
Execute inc_file
End if
End Sub
%>
*****************

file (to be included): 2.asp
*******************
<% response.Write("this is a page #2 but here is a var from page 1: <b>" & var_pageone &"</b>")%>
**************************

I think that on one of the asp web sites there was an article or a post regarding using FSO for a similar task.
Again, I'm not sure if it's worth using although those two pages above seemed to be working fine and vars from page1 can be used on page 2...
I'd appreciate your input.
thank you
_________________
GeorgeS
View profile  Send private message
CMonteiro_PT
Posted: 06/25/2004, 6:59 AM

Hi there to all,

The best way to do this I agree with GeorgeS but if you can't use this,
maybe this could be an answer:

Function megaInclude(filepath)
On Error Resume Next
Dim FSO, file
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set file = Fso.OpenTextFile(Server.Mappath(filepath))
megaInclude = file.readAll
if (megaInclude = "") then
megaInclude = "Nothing exists or empty!"
End if
file.close
Set file = nothing
Set FSO = nothing
Response.Write(megaInclude)
End Function

'megaInclude("22112000.htm")
'megaInclude("news/22112000.htm")


A hug from Portugal
-----
CM

Turn off your script-blocking feature on your antivirus software, and enjoy
CCS!
http://docs.codecharge.com/studio/html/CommonErrors/PageIIS.html?toc
-----

"GeorgeS" <GeorgeS@forum.codecharge> escreveu na mensagem
news:640d4ecddba6f8@news.codecharge.com...
> What about using server.execute("page_name.asp")?
>
> _________________
> GeorgeS
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

CMonteiro_PT
Posted: 06/25/2004, 7:12 AM

Ohhh!

I forgot. You can use server.execute like this:

Dim strPath
srtPath = request.querystring("URL")
If Not strPath="" then
Server.execute(strPath)
'or like this
'Server.execute(strPath&"MyPage.asp")
'Server.execute(strPath&".asp?DateTime="&now())
else
Response.write "Nothing to see!"
end if

A hug from Portugal
-----
CM

Turn off your script-blocking feature on your antivirus software, and enjoy
CCS!
http://docs.codecharge.com/studio/html/CommonErrors/PageIIS.html?toc
-----

"GeorgeS" <GeorgeS@forum.codecharge> escreveu na mensagem
news:640d4ecddba6f8@news.codecharge.com...
> What about using server.execute("page_name.asp")?
>
> _________________
> GeorgeS
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>


JerryVT
Posted: 06/25/2004, 12:34 PM

Hi CMonteiro_PT,

Thank you sharing your code with us!
Your megaInclude function is working fine for me.

Question.
If you'll try creating includable page in CCS and execute if from a different page like this:
Server.execute("page.asp?var="&var)
it will give you an error.

On Microsoft web site it says :
"The Path parameter must not contain a query string, or IIS returns an error"
http://msdn.microsoft.com/library/default.asp?url=/libr...om_seromexe.asp

Are you sure that your example was working?

Jerry
JerryVT
Posted: 06/25/2004, 12:50 PM

BTW, GeorgeS's example is working also.
It acts exacly like include & you can use variables from the calling page.
The only difference is that you have to Response.Write html code.

Jerry

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.