View Full Version : passing variables to sub-page using server.execute
sweenster
01-31-2005, 12:25 AM
i'm using server.execute() to include a sub-page within another page, however I would like to be able to pass variables to the sub-page from the main page. can this be done with server.execute()?
Morgoth
02-02-2005, 01:56 AM
I don't think you can.
I ran some tests but I don't know how to do it.
However, you can use <!--#INCLUDE FILE="file.asp" -->
But you need SSI, and you probibly have it on your server, so it's worth a try.
Any variable made before the include, can be used and changed and whatever inside of file.asp.
Tell me if this works.
ghell
02-02-2005, 09:47 AM
#include server.execute and server.transfer all transfer the page state over (with all the variables) but for some reason only #include seems to transfer functions you have made on the original file *shrugs*
fractalvibes
02-02-2005, 04:26 PM
Any form variables, query string variables that were available to the original page should be available to the page transfered to via server.execute, methinks.
fv
Morgoth
02-03-2005, 03:33 AM
Any form variables, query string variables that were available to the original page should be available to the page transfered to via server.execute, methinks.
fv
I tried it, and it doesn't seem to work for me.
I added my own string variables to this little example here:
http://docs.sun.com/source/817-2514-10/Ch9_ASPBuiltIn143.html
ghell
02-03-2005, 09:14 AM
works fine for me, im using iis 6 not chillisoft though, heres the code i ran:
(the page run was ServerExecute.asp?page=requeststuff.asp)
ServerExecute.asp:<%
Response.Write "on page 1, transfering to page2:<hr>"
Server.Execute(Request.QueryString("page"))
Response.Write "<hr>back on page 1"
%>requeststuff.asp:Request.QueryString = '<%=Request.QueryString%>'<br>
Request.Form = '<%=Request.Form%>'and heres the result:on page 1, transfering to page2:
--------------------------------------------------------------------------------
Request.QueryString = 'page=requeststuff.asp'
Request.Form = ''
--------------------------------------------------------------------------------
back on page 1
Morgoth
02-05-2005, 05:19 AM
works fine for me, im using iis 6 not chillisoft though, heres the code i ran:
(the page run was ServerExecute.asp?page=requeststuff.asp)
ServerExecute.asp:<%
Response.Write "on page 1, transfering to page2:<hr>"
Server.Execute(Request.QueryString("page"))
Response.Write "<hr>back on page 1"
%>requeststuff.asp:Request.QueryString = '<%=Request.QueryString%>'<br>
Request.Form = '<%=Request.Form%>'and heres the result:
That's not what he meant.
He meant this:
Page1.asp
<%
Dim strVar
strVar = "This Text"
Response.Write("Page 1 <br>")
Server.Execute("page2.asp")
Response.Write("Page 1 check: """ & strVar & """")
%>
Page2.asp
<%
Response.Write("Page 2 <br>")
Response.Write("Page 2 check: """ & strVar & """<br>")%>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.