473,387 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Accessing/Passing an object variable to a Server.Execute Include

Hi everyone,

I've been browsing this and a few other related newsgroups trying to
get my head around this problem, and so far all the trails seem to go
cold, without an acceptable solution being reached. I'm posting here
because there seems to be a few MVP's knocking around, and if they dont
know, then it's a safe bet nobody does.

I'm beginning to think that what I want to do is simply not possible -
but i'll put it out there once more.

Here goes: I'm writing a content managaement system - and i'm making
use of dynamic includes via the "read a text file" technique, and then
substitiuting values into markers in the template.

For example. I have a text "template" file, that contains the html for
the dynamic page. Within the html text file are various markers that
are replaced at run time with statements such as:

myText = replace(myText, "##topnav##", topheader)

which works great. However, this substitution has to be hard coded
somewhere into the application. This is obviously suboptimal - as for
every new template I add, I need to write a specific "build" function
for that page's substitutions.

My planned work around, was to make the "build" function an asp page
that is Server.Executed when required....and making the build function
file editable through the CMS. Thus allowing me to edit the way the
page is built without editing core logic.

The problem is how I pass the variables to be substituted into the
template into the Server.Execute file. Here's the catch: I need to pass
Objects into the build file - specifically a dictionary object that
contains all the substitutions to be made.
i.e. obj.item( topheader ) = "this is the page header"
obj.item( phonenum ) = "017738393" etc.

I simply cant get this to work. I hope i've explained it clearly
enough. Anybody got any ideas?
One final question: Is it possible to specifiy a dynamic filename for
a Server.Execute?

i.e.
Dim fName
fName = "buildSalesPage.asp"
Server.Execute fName

Thanks for reading this ridiculously long post.
Hope somebody out there can offer a solution - or a work around. I'm
sure other CMS systems must have similar problems.

Thanks again.
Tony

Oct 17 '06 #1
2 2960

"Sike" <to*********@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Hi everyone,

I've been browsing this and a few other related newsgroups trying to
get my head around this problem, and so far all the trails seem to go
cold, without an acceptable solution being reached. I'm posting here
because there seems to be a few MVP's knocking around, and if they dont
know, then it's a safe bet nobody does.

I'm beginning to think that what I want to do is simply not possible -
but i'll put it out there once more.

Here goes: I'm writing a content managaement system - and i'm making
use of dynamic includes via the "read a text file" technique, and then
substitiuting values into markers in the template.

For example. I have a text "template" file, that contains the html for
the dynamic page. Within the html text file are various markers that
are replaced at run time with statements such as:

myText = replace(myText, "##topnav##", topheader)

which works great. However, this substitution has to be hard coded
somewhere into the application. This is obviously suboptimal - as for
every new template I add, I need to write a specific "build" function
for that page's substitutions.

My planned work around, was to make the "build" function an asp page
that is Server.Executed when required....and making the build function
file editable through the CMS. Thus allowing me to edit the way the
page is built without editing core logic.

The problem is how I pass the variables to be substituted into the
template into the Server.Execute file. Here's the catch: I need to pass
Objects into the build file - specifically a dictionary object that
contains all the substitutions to be made.
i.e. obj.item( topheader ) = "this is the page header"
obj.item( phonenum ) = "017738393" etc.

I simply cant get this to work. I hope i've explained it clearly
enough. Anybody got any ideas?
One final question: Is it possible to specifiy a dynamic filename for
a Server.Execute?

i.e.
Dim fName
fName = "buildSalesPage.asp"
Server.Execute fName

Thanks for reading this ridiculously long post.
Hope somebody out there can offer a solution - or a work around. I'm
sure other CMS systems must have similar problems.
Yes you can call server execute using a variable name to specify the path to
be executed.

As no doubt you have discovered putting an object into the session is a no
no.

However something which can behave much like a dictionary is an XML node and
it's attributes.
You can then assign the XML string to a session variable and reconstitute
the XML node in the server executed page:-

Dim oDOM : Set oDOM = Server.CreateObject("MSXML2.DOMDocument.3.0")
oDOM.loadXML "<root />"
Dim oDictNode : Set oDictNode = oDOM.documentElement

oDictNode.setAttribute("topheader") = "this is the page header"
oDictNode.setAttribute("phonenum") = "017738393"

Session("params") = oDOM.xml

Server.Execute "servicePages/service1.asp"

'servicePages/service1.asp
<%
Dim oDOM : Set oDOM = Server.CreateObject("MSXML2.DOMDocument.3.0")
oDOM.loadXML Session("params")
Dim oDictNode : Set oDictNode = oDOM.documentElement

myText = replace(myText, "##topnav##", oDOM.getAttribute("topheader"))
Having said that if you create an XML DOM you might as well take a look XSLT
which is designed to transform XML into output such as HTML. See:-

http://www.w3schools.com/xsl/xsl_languages.asp

However it might be overkill for what you need.

Anthony

Oct 17 '06 #2

Anthony Jones wrote:
"Sike" <to*********@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Hi everyone,

I've been browsing this and a few other related newsgroups trying to
get my head around this problem, and so far all the trails seem to go
cold, without an acceptable solution being reached. I'm posting here
because there seems to be a few MVP's knocking around, and if they dont
know, then it's a safe bet nobody does.

I'm beginning to think that what I want to do is simply not possible -
but i'll put it out there once more.

Here goes: I'm writing a content managaement system - and i'm making
use of dynamic includes via the "read a text file" technique, and then
substitiuting values into markers in the template.

For example. I have a text "template" file, that contains the html for
the dynamic page. Within the html text file are various markers that
are replaced at run time with statements such as:

myText = replace(myText, "##topnav##", topheader)

which works great. However, this substitution has to be hard coded
somewhere into the application. This is obviously suboptimal - as for
every new template I add, I need to write a specific "build" function
for that page's substitutions.

My planned work around, was to make the "build" function an asp page
that is Server.Executed when required....and making the build function
file editable through the CMS. Thus allowing me to edit the way the
page is built without editing core logic.

The problem is how I pass the variables to be substituted into the
template into the Server.Execute file. Here's the catch: I need to pass
Objects into the build file - specifically a dictionary object that
contains all the substitutions to be made.
i.e. obj.item( topheader ) = "this is the page header"
obj.item( phonenum ) = "017738393" etc.

I simply cant get this to work. I hope i've explained it clearly
enough. Anybody got any ideas?
One final question: Is it possible to specifiy a dynamic filename for
a Server.Execute?

i.e.
Dim fName
fName = "buildSalesPage.asp"
Server.Execute fName

Thanks for reading this ridiculously long post.
Hope somebody out there can offer a solution - or a work around. I'm
sure other CMS systems must have similar problems.

Yes you can call server execute using a variable name to specify the path to
be executed.

As no doubt you have discovered putting an object into the session is a no
no.

However something which can behave much like a dictionary is an XML node and
it's attributes.
You can then assign the XML string to a session variable and reconstitute
the XML node in the server executed page:-

Dim oDOM : Set oDOM = Server.CreateObject("MSXML2.DOMDocument.3.0")
oDOM.loadXML "<root />"
Dim oDictNode : Set oDictNode = oDOM.documentElement

oDictNode.setAttribute("topheader") = "this is the page header"
oDictNode.setAttribute("phonenum") = "017738393"

Session("params") = oDOM.xml

Server.Execute "servicePages/service1.asp"

'servicePages/service1.asp
<%
Dim oDOM : Set oDOM = Server.CreateObject("MSXML2.DOMDocument.3.0")
oDOM.loadXML Session("params")
Dim oDictNode : Set oDictNode = oDOM.documentElement

myText = replace(myText, "##topnav##", oDOM.getAttribute("topheader"))
Having said that if you create an XML DOM you might as well take a look XSLT
which is designed to transform XML into output such as HTML. See:-

http://www.w3schools.com/xsl/xsl_languages.asp

However it might be overkill for what you need.

Anthony
Thanks very much Anthony - your post have given me just the inspiration
i needed.

Top draw my friend.

Oct 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Erik Andersson | last post by:
Hi! <? class Foo { function getMessage() { return "foo"; } } class Bar { function getFoo() {
0
by: Aaron | last post by:
The following code works fine when previewing a Crystal report using ASP, EXCEPT when it gets to a report using a SubReport and its associated parameters. The whole report just comes up blank with...
3
by: Fredrik/Sweden | last post by:
Hi folks ! got this problem... i have a table 'Accounts' in my database, which contains a bunch of users. From the main menu i choose "edit user" and all users in the db are presented in a table....
8
by: Carolyn Speakman | last post by:
is it in any way possible to include a file specified by a variable name? Thanks, Carolyn
7
by: TNGgroup | last post by:
Hi, I have some troubles with the correct syntax, hope to get some help. This is the intention: This is the code I'd like to use. url: http://webserver/ta.asp?artnr=04001 Code ta.asp:...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
5
by: Bill | last post by:
I need to pass a static parameter to an included ASP file. I'm thinking about using this with a query string, but upon reflection I'm not sure how I can do this. For example: ---file start:...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
3
by: Dave Kelly | last post by:
From a html page menu I need to pass 2 variables. <a href="signup.php?var1=list-PINSS.php&var2=blurb-PINSS.php"><h3>Padre Island National Sea Shore</h3></a><br> These go to a php web page...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.