...

View Full Version : variable includes



ghell
10-13-2003, 08:48 PM
i was wondering if there was any way to include like
<%=variable%>.asp or some other way of this, i am trying to do a
default.asp?page=news and it includes news.asp or something like that, the only way i have seen it working is with the webbridge object like


<%if Request.QueryString("page") = "" then
page = "news"
else
page = Request.QueryString("page")
end if%>
<object type="text/x-scriptlet" width=100% height="250" data="<%=page%>.asp" VIEWASTEXT>
</object>

which only works on IE4+ and you cant select it properly as well as some other coding problems on pages that are designed to work only from the default page so that they cannot be used on their own

Roy Sinclair
10-13-2003, 09:44 PM
With IIS 5.0 or later you can use: Server.execute to call one ASP page from another.

See: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnserv/html/server02282000.asp

M@rco
10-14-2003, 01:02 AM
May I suggest the following light reading:
http://www.4guysfromrolla.com/webtech/080199-1.3.shtml
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=7651&lngWId=4

;)

whammy
10-14-2003, 03:17 AM
That second link leaves a bit to be desired, I'd recommend learning FileSystemObject thoroughly on your own (i.e. http://www.w3schools.com), and reading his article for ideas if you must.

However the first link is even better reading, I always recommend 4guysfromrolla, it's a great ASP site. I have learned much from there. :)

Caffeine
10-14-2003, 09:18 AM
Whammy, In the days when I learned asp somebody recommended me to stay away from fso. When the fso access a file, it can only handle that request to one visitor at the time. This will mean it will be incredible slow when the server is busy and has many concurrent users.

Do you have any info on this, I'm just curious if this is true or not.

jeskel
10-14-2003, 10:31 AM
Originally posted by Caffeine
Whammy, In the days when I learned asp somebody recommended me to stay away from fso. When the fso access a file, it can only handle that request to one visitor at the time. This will mean it will be incredible slow when the server is busy and has many concurrent users.



Just remember I heard the same thing... one night very late after a party (is it the reason why I forgot it?;) ) it seems weird... Never had the opportunity to test it. It's kinda off-topic but well whammy, if you have infos about it I'm also interested...

M@rco
10-14-2003, 11:59 AM
Originally posted by Caffeine
Whammy, In the days when I learned asp somebody recommended me to stay away from fso. When the fso access a file, it can only handle that request to one visitor at the time. This will mean it will be incredible slow when the server is busy and has many concurrent users.

Do you have any info on this, I'm just curious if this is true or not. I don't know for a fact whether the FSO is *that* bad, but it certainly is pretty inefficient.

For scalability, you should use the FSO for everything APART from the actual loading and saving of files. For *those* operations you should use the ADO.Stream object (see your ADO reference documentation).

For example, here are some stream-based functions from my code library:
'Load a file from disk
Function LoadStream(FilePath)
Dim objStream

If FileExists(FilePath) Then
Set objStream = Server.CreateObject("ADODB.Stream")

objStream.Type = 1 'adTypeBinary=1
objStream.Open

objStream.LoadFromFile FilePath
LoadStream = objStream.Read

objStream.Close
Set objStream = Nothing
Else
Set LoadStream = Nothing
End If
End Function


'Save a file to disk
Function SaveStream(FilePath,Data)
Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream")

objStream.Type = 1 'adTypeBinary=1
objStream.Open

objStream.Write Data
objStream.SaveToFile FilePath, 2

objStream.Close
Set objStream = Nothing
End Function

jeskel
10-14-2003, 01:50 PM
Thanx M@rco, very very helpfull :thumbsup: :thumbsup: I'll try this as soon as possible;)

M@rco
10-14-2003, 01:56 PM
Y'welcome! Just noticed that I'd left in a call to my debugging function, so please remove it. (I've edited the code above)

jeskel
10-14-2003, 04:55 PM
ok no problem. :)

whammy
10-15-2003, 04:54 AM
I only use FSO for things that very few people will be accessing (like a client's account manager accessing a .csv file as a report, or a simple blog chat client), so I haven't run into any problems with it, at all.

I _definitely_ would not use FSO in place of a database solution, if that's what you're wondering.

They each have their own place - and it takes an understanding of relational databases to know this. You have to determine beforehand how many people could possibly access this information concurrently, and the MAIN thing to understand is what I'm _always_ trying to get across:

What are you trying to accomplish?

That's the first thing that MUST be understood before you begin programming any application.

:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum