asp tags in include line
-
Hello
Is there any way to create the include file line using the asp tags - <% and %>
e.g.
Code: <!--include file="<%="mypage.asp"%>"-->
Normal line
Code: <!--include file="mypage.asp"-->
The example i gave doesn't work; i am asking if anyone knows a way you can use asp code for the include line.
Thanks for any help -
http://www.codefixer.com/tutorials/dynamic_includes.asp
If you use the method Above be aware that including files Includes ALL THE CODE in the file even though it in a if then or Select case it still includes the code.
good examples:
http://www.asp101.com/articles/michael/dynamicincludes/default.asp
What I have also done is:
Code:
'FilesystemObject to read file and put it a VAR
'Read on the EXECUTE Function
'http://www.devguru.com/Technologies/vbscript/quickref/regexp_execute.html
Execute (varthatcontainscontentsofDynamicInclude)
-
Sorry but i cannot use the first one because i don't know the filename before it is going to be used, and the second one doesn't execute that asp tags in the replace part, it just will write <% as html not executed by the asp parser.
I didn't really want to use the fso because i wanted to make a template system which had a 'inc-header.asp' and 'inc-footer.asp' file in the template dir
e.g. /templates/bluedesign/inc-header.asp
The fso would be used heaps then to find the include section using InStr whcih would greatly slow down the server espically with heaps of ppl.
Thanks i don't think there is any other way i can do it so i will have to think of another way to design the templete system. -
If your templates for header and footer do not need to reference anything in the main page - i.e they generate self-contained chunks of html code - you could use server.execute(sVarContainingPageName) e.g.
Code:
Dim sHeaderName
sHeaderName = "templates/bluedesign/header.asp" ' or whatever you need
Call server.execute(sHeaderName)
:
: Generate the main page here
:
Dim sFooterName
sFooterName = "templates/bluedesign/footer.asp" ' or whatever you need
Call server.execute(sFooterName)
The code is not included but you can generate complete sections of output to response in each. In this example the header and footer pages refer to the same request and response objects as the calling page. -
with Server.Execute if the template has a Response.Write then does that get written where the
Call server.execute(sHeaderName)
line is?
Visual InterDev doesn't even say that Server.Execute exists!
Damn because the page url is used for the login return page.
Could i put the url in a session varible and then use that in the template page?
Thanks so much for all of your help -
Server.Execute works, cool
-
when you said
Quote: i.e they generate self-contained chunks of html code - you could use server.execute(sVarContainingPageName)
Does this mean that if u have a varable on a page and use the server.execute code the executed page is executed seperate to the main page
And while i am here i was think of a db with a file, if i wanted to execute asp code from a field in a db is the only way to create a temp file and then execute it and then delete it?
Thanks so much u rock -
Quote: Does this mean that if u have a varable on a page and use the server.execute code the executed page is executed seperate to the main page
Yes. Server.Execute causes the given page to be loaded (if not already) and executed as if separate from the calling page, with no access to any of the variables or functions in the calling page but using the same Request and Response object as the calling page. This is the same as Server.Transfer, except that after Server.Execute, control returns to the calling page when the called page has finished, wherease with Server.Transfer it does not. Note, if you have Response.End in your called page then that's the end - control does not return to the caller.
Quote: if i wanted to execute asp code from a field in a db is the only way to create a temp file and then execute it and then delete it
Well, that is one way, but if I understand you right, then I think you could use the vbscript Execute statement or Eval function to run the code fragment without needing to create a separate script. These have the advantage of having access to in-scope variables of the script being run. See Eval function and Execute statement in MSDN for more information. -
i for got 5 emails when Veritant posted i don't know why
I could use Server.Execute but i am hoping that i can find another way to do this. Server.Execute doesn't really work the way i want but it may have to do.
I don't know if i am stupid or if u didn't understand what i was really asking, but i will try to explain it more.
If i have a string that contains asp code tags in it, i wanted to know if i can some how execute it w/o creating a temp file with a include line? Like a parser that can be executed with a string and returns the outputted html.
Thanks so much for your time Veritant and also your help Nagash -
Quote: If i have a string that contains asp code tags in it, i wanted to know if i can some how execute it w/o creating a temp file with a include line? Like a parser that can be executed with a string and returns the outputted html.
Yes you can, but you would use the vbscript Execute statement , not the ASP method Server.Execute - they are different things. For example:
Code:
dim sVBScript : sVBScript = "response.write ""<BR>This will be output to response"""
Execute( sVBScript )
will execute the statement in sVBScript as if it was part of the script in which it is being executed. The vbscript statement Eval works in a similar way, but actually returns a value. See the msdn articles mentioned in my previous posting for more information about these two statements.
Perhaps you could just store HTML in your database field, then you could simply write it out using Response.Write -
Thanks so much
the only thing is that
Quote: will execute the statement in sVBScript as if it was part of the script in which it is being executed.
Is this True what you said so all variables will be able to be used, etc
The reason i cannot just have html and write it is that it has asp code in it because these are the templates for my site and varaibles are used and db connection.
One more simple question i hope. I am starting to design a web portal in asp but i don't know whether i should learn asp.net and use that since that is the new and greatest asp langauge?
Thanks so much you rock -
The code being run inside the Execute statement will have access to variables that are local and global in scope at the point of execution of the Execute statement. But if you declare a sub or function inside the code being run by the execute, the code inside the sub or function sees only variables that are global in scope.
See the MSDN articles mentioned in my earlier posting for more information about Execute and Eval. -
Quote: One more simple question i hope. I am starting to design a web portal in asp but i don't know whether i should learn asp.net and use that since that is the new and greatest asp langauge?
Hmm.. well here is a different kettle of fish. I cannot comment without knowing much more about what functions/features you intend to provide through your portal, how quickly you need to deploy it, what lifetime you expect for it, how much time/money you have to spend, etc etc. But if you have the time and are keen to learn asp.net then... hey! go for it! -
Thanks but u will not be impressed with what i have to say.
I have i new idea for my template/theme system, i am going to use files like footer.html, header.html, etc; these files have pieces of text like '%SiteName%' in them to i will use the replace function and replace them with the real varaible. The only thing is that; is the FSO the only way to open the file up?
With the ASP.net question i think that i will make it classic asp because asp.net is not and will not be supported on Unix & Linux through Apache using Sun One ASP; also many current sites don't have asp yet. I think i will make it in classic asp and then later rewrite it in asp.net so then i have Classic ASP & ASP.NET editions for both types of people/server.
Thanks for you help it is greatly appreciated -
i would just like to add for James Cowley to look into
I got 14 email when Veritant posted his last two posts
That is 7 emails for each post!
Thanks for reading if u did, u most likely didn't because u didn't see it and r busy -
If you want to have a more modern architecture you might consider using generating XML using MSXML objects, then transforming the XML into HTML using XSLT tranforms. It is a very powerful way of separating content from presentation, and could help with the template style etc. And as .net is centred on using XML, it could put you in a good position for moving to ASP.NET later.
Otherwise, your idea of using HTML with parameters that are replaced sounds fine, provided you can keep it simple and don't end up writing some sort of scripting language of your own with a parser!
Whatever you choose, good luck! -
Hello
XML sounds like it is a more modern architecture as u said, but is it supported by servers w/o .net framework? Most likely not.
It sounds very powerful but because later i am not converting my portal from asp to asp.net it is not really a issue; I am going to rewrite in asp.net to take full advantage of asp.net's features and then use XML and XSLT.
The replacing thing will be simple, things like
%SiteName%
%LatestTopics%
%NewestMember%
%NoMembersOnline%
etc
You have given me so much help, i asked b4
Quote: for replacing the wordsThe only thing is that; is the FSO the only way to open the file up?
And also which type of dynamic theme varaible do u think i should use?
%SiteName%
$SiteName
{SiteName}
<SiteName>
?SiteName?
&SiteName&
[SiteName]
or something else, ppl will have to add these to there themes when they make their themes
Thanks so much for your help
Note: I receivied 9 emails when Veritant last posted! -
do u think it is alright to use the Application object to store the theme/template/skin and open it up on the Application_OnStart in global.asa?
Thanks -
If im not mistaken application_onstart uses Memory on the server right.
Think about scalability.
What happens to the memory when theres 200 + users ?
what happens when theres 1000+?
You can use Microsoft Web Application Stress Tool to look at this.
I found some URLS on template coding.
http://www.4guysfromrolla.com/webtech/091300-1.shtml
http://www.4guysfromrolla.com/webtech/061402-1.shtml
http://www.aspwire.com/brief.asp?6323
http://www.4guysfromrolla.com/webtech/020400-1.shtml
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6676
http://www.asp101.com/articles/paul/templating/default.asp -
thanks so much for all of them i have saved them all and i will have a look at all the code and read all of the articles
one thing is that 1 of them templates are simliar to what i am doing, the only thing is using the fso on every page for every person is a bit of an over kill so i thought of using the application object to store it i know that it uses ram, but other than that i have to open the template on every page to display the wrap around the pages.
I was thinking of using my db to store the templates/themes, because u can change the theme in your admin centre but only one theme is displayed at once.
So what do u think about that?
Thanks for your time -
is the only was to talk to James Crowley through email?
because i got 11 emails when Nagash replied, i thought that i had 11 new emails in about 10mins, because i just checked it and then there were 11
thanks -
thanks the links u gave me were the same but that didn't matter because i found what i wanted
Quote: Tip 2: Cache Frequently-Used Data in the Application or Session Objects
The ASP Application and Session objects provide convenient containers for caching data in memory. You can assign data to both Application and Session objects, and this data will remain in memory between HTTP calls. Session data is stored per user, while Application data is shared between all users.
Thanks you helped me heaps, i was going to ask one more question but u are most likely sick of my questions
o here it is anyway, u only have to answer it if u want.
In an *.asa because it is VBScript u cannot use i asp pages, i wanted to use my dbconnection file but u cannot have the <% and %> tags in the asa file, do u know a way if not then don't worry i will just make it so that ppl change the db connection in the 2 places, annoying but o well.
Thanks heaps u guys are really good. -
Never put your connection in the ASA file. ONLY put your connexction string.
DO:
Constr = "connectionto DB string"
DONT:
Conn.open ..... blah blah -
It should be ok to save an fso in the application, but you may need to check that the threading model works ok. The problem of scaling that Nagash raised should only be an issue if you are trying to save things that are specific to each user, rather than shared by all the users. Don't save user-specific stuff in the application object as that will certainly cause you problems. The main difficulty is knowing when to discard something you have saved.
As a further thought, how about reading the contents of the various templates strings and saving them in the application object under different keys. Then, you can just retrieve the right one for the current context and output it using response.write. That would be very efficient an avoid using the fso. -
Nagash:
i had a read of then pages but they don't really give me a way to use info from a db and put it into my application object
if u could further explain what u meant that was one them pages it would be appraiated
Veritant:
i am saving the file straight from the fso, so it will still have all the tags to be changed when the asp pages run, eg. {sitename} {username}
so there will be only one template for all the users, but i was thinking of having multiple templates that members can chose and then they will be loaded into the application object but they are the same for all users, and u chose in your admin section which templates are active to save memory.
Thanks for all of the help, i hope to help some1 like u guys are doing now to me, Thanks again -
15 years agoby Alexpizzoferro
Alexander Pizzoferro
Guildford, United KingdomJoined 15 years agoIs it possible to link absolutely to an include?
For example:
<!--#include file="http://www.site.com/include.asp"-->
I am reorganising my site into sub domains and do not want multiple copies of the includes.
Thanks -
This is an old topic, was 2 and a half years ago. I just reread it and it brings back memories.
This is not possible because you cannot get the ASP code from a web server. If you typed http://www.site.com/include.asp into your browser you would only get HTML because the code is executed before the web browser gets it. Your web server needs access to the file on a hard drive and not the executed file.
Hope that helps. -
15 years agoby Alexpizzoferro
Alexander Pizzoferro
Guildford, United KingdomJoined 15 years agoAh think you misunderatand.
I was just not writing the full code.
I meant the path to the include file.
Is this possible?
<--#include file="http://www.site.com/include.asp"-->
I want to use an absolute address like this instead of
<--#include file="./include.asp"-->
I am going to be using sub domains so if i use the ./ which points to the root, it takes the subdomain as the root instead of the main domain.
Thanks for your help.
Glad i brought back some memories also. -
Im not too sure with that one, it might work, it all depends on how Microsoft coded the ISAPI filter (ASP paser). But i would expect that you can only have relative or absolute; i really doubt there would be support for using any URL. You can give it a try but i doubt it would work. IIS will provide an error telling you that the path is no relative or absolute.
However because you are using subdomains wouldn't your subdomains be in the same file system? So you can still include them using the path to the subdomains folder.
Hope that helps. -
You cannot use the http protocol in includes. These are file system paths to files that your web server has direct access to. There are two syntaxes for includes:
USING "FILE" KEYWORD
<!-- #INCLUDE FILE="path" -->
which includes a file using a physical path relative to the current .asp file, whereever that file is in the directory tree. So this could include files that are not directly visible to web browsers by referring to the parent folder of the current folder using ../ notation, for example:
<!-- #INCLUDE FILE="../../myincludes/includefile.inc" -->
but remember this is always relative to the current page, so if you move the page around on your site, you have to be sure you adjust the path to reach the right place for the includes.
USING "VIRTUAL" KEYWORD
<!-- #INCLUDE VIRTUAL="/path" -->
which includes a file using a path relative to the root of the current web site. This enables you to define a virtual folder, say "includes", in your web server which points to a folder in quite a separate location from the folder containing your site and the current page. In this case the path must start with "/", and it has the distinct advantage that wherever the page is located in the site, the path remains the same - always relative to the root of the site. This approach is much better if you are using the same includes from lots of places, even from different web sites, because you can set up virtual folders on each site to point to the same physical folder on your disk.
If you really want to get at text held in some other web location you could do it using XML over HTTP, but that would be very different from using an include.
Hope that helps. -
15 years agoby Alexpizzoferro
Alexander Pizzoferro
Guildford, United KingdomJoined 15 years agoOk Thanks for that.
But can this work with subdomains?
I have tried a few things but the subdomain is then counted as the root.
I have also tried going out of some dirs and back into others with ../../ etc but this also doesnt work.
This my hosting company does not allow me to do this outside the httpdocs dir.
Any ideas?
Post a reply
.NET forum discussion
-
edmonton female escort services near me
by canadapleasure (0 replies)
-
Bagaimana memenangkan $ 1,54 miliar dalam Mega Jutaan
by gametogelan (0 replies)
-
input integer from text file and output text file
by shmilon (0 replies)
-
cSharp stuck at exercise
by xander_Michiels (0 replies)
-
Need help in selected the Tax Audit Year from drop down menu and displaying results for the selected year
by citymumbai (0 replies)
Quick links
Recent activity
- arif ahmad replied to How to receive data in web ...
- William Thompson replied to What is the name of the Win...
- Sameera Piyadigamage replied to Point of Sale Developers: H...
- Scott Carline replied to 4 x C# Developers for large...
- Rajendra Dhakal replied to Restore SQL Server text dat...
- cloud rainda replied to How to convert between TS f...
Enter your message below
Sign in or Join us (it's free).