473,898 Members | 2,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2984

"Sike" <to*********@gm ail.comwrote in message
news:11******** *************@h 48g2000cwc.goog legroups.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.CreateOb ject("MSXML2.DO MDocument.3.0")
oDOM.loadXML "<root />"
Dim oDictNode : Set oDictNode = oDOM.documentEl ement

oDictNode.setAt tribute("tophea der") = "this is the page header"
oDictNode.setAt tribute("phonen um") = "017738393"

Session("params ") = oDOM.xml

Server.Execute "servicePag es/service1.asp"

'servicePages/service1.asp
<%
Dim oDOM : Set oDOM = Server.CreateOb ject("MSXML2.DO MDocument.3.0")
oDOM.loadXML Session("params ")
Dim oDictNode : Set oDictNode = oDOM.documentEl ement

myText = replace(myText, "##topnav## ", oDOM.getAttribu te("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*********@gm ail.comwrote in message
news:11******** *************@h 48g2000cwc.goog legroups.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.CreateOb ject("MSXML2.DO MDocument.3.0")
oDOM.loadXML "<root />"
Dim oDictNode : Set oDictNode = oDOM.documentEl ement

oDictNode.setAt tribute("tophea der") = "this is the page header"
oDictNode.setAt tribute("phonen um") = "017738393"

Session("params ") = oDOM.xml

Server.Execute "servicePag es/service1.asp"

'servicePages/service1.asp
<%
Dim oDOM : Set oDOM = Server.CreateOb ject("MSXML2.DO MDocument.3.0")
oDOM.loadXML Session("params ")
Dim oDictNode : Set oDictNode = oDOM.documentEl ement

myText = replace(myText, "##topnav## ", oDOM.getAttribu te("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
2525
by: Erik Andersson | last post by:
Hi! <? class Foo { function getMessage() { return "foo"; } } class Bar { function getFoo() {
0
5450
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 this error message: "The Error Message was: Error detected by database DLL.from: Crystal Reports ActiveX Designer". What am I doing wrong in the SubReport section below and how do I properly pass in sproc params to the subreport? Thanks. ...
3
4998
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. The first column 'Pnr' is a unique ID for each user that i made appear as a link. clicking on one userID should present a form where the picked users userdata is already filled in so i can easily edit it and then move on to submit the form to...
8
8341
by: Carolyn Speakman | last post by:
is it in any way possible to include a file specified by a variable name? Thanks, Carolyn
7
17714
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: strSql = "Select * from ta where ta_nr = %artnr%"
3
14972
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) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
5
11138
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: FIRST.ASP ------ <% Server.Execute("second.asp?a=1") %> <!--- ***** or ***** --->
58
10223
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 code... TCHAR myArray; DoStuff(myArray);
3
2418
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 and are used thusly. <?php include ($_SERVER); ?//this is line 3 <?php include ($_SERVER); ?// line 5
0
9992
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11254
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10853
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10480
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9658
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8034
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4295
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.