Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing a parameter in the querystring with FSO?

Status
Not open for further replies.

wrbodine

Programmer
Aug 24, 2000
302
US
Hi

From the following link, I found a workaround for how to use an include file dynamically:


This is working fine, where I use a filename like "../Include/FileName.asp". My question is, is there a way to do this same kind of thing with a variable passed in the URL, where the file name is something like "../Include/FileName.asp?UserName" & UserName

When I try and do this I get an "Invalid Path Character" error.

Thanks,
Ray
 
file name is something like "../Include/FileName.asp?UserName"

? is not a valid file name character under a Windows OS, hence the error message. What is the actual name of your file? Something like: TemplateClient.inc

And you are attempting to pass the Client portion of the filename? Like so: TemplateIBM.inc or TemplateIntel.inc

If so, presuming you are using the getFileContents function from the URL you posted above:

strFile = "Template" & Request("UserName") & ".inc"
strInclude = getFileContents(strFile) Jon Hawkins
 
Thanks for responding Jon,

Actually, that part is working fine, but I'm using a file with a .asp extension, not .inc, and I'm wanting to pass parameters through the URL. The way this is normally done is, after the filename:
1st parameter: ?ParamName=ParamValue
2nd parameter: &ParamName=ParamValue

example:
&quot;../Include/aspFile.asp?variable1=90&variable2=<%varValue%>&quot;

in the example varValue is a variable that can have different values....

 
I'm aware of how to use query string variables. But regardless of what parameters you are passing, the name of the physical file on the server remains the same:
&quot;../Include/aspFile.asp?variable1=90&variable2=<%varValue%>&quot;

The file name is still aspfile.asp.

Are you saying you are passing a url (like above) to GetFileContents and need to parse out the filename? If so, use something like:

MyString=&quot;../Include/aspFile.asp?variable1=90&variable2=<%varValue%>&quot;
nPos=Instr(1,MyString,&quot;?&quot;)
MyFile=Left(MyString,nPos-1)
MyInclude=GetFileContents(MyFile)

If I've misunderstood your question, my apologies, maybe someone else will better understand your request and be able to propose a viable solution. Jon Hawkins
 
Thanks again; I may not have communicated the issue that well. When I get the contents of the page through GetFileContents the page needs to be dynamic, its content changing depending on the variables I pass it. So when I call GetFileContents (or some other alternative, if there is one) I need to pass the variables in the query string in that call, so the page can get its data based on the variables. Right now it blows up when I try that, in the line
Set objText = objFSO.OpenTextFile(Server.MapPath(strIncludeFile))

When I remove Server.MapPath it still blows up
 
In your above posting, the following line:

&quot;../Include/aspFile.asp?variable1=90&variable2=<%varValue%>&quot;

looks like it should be:

&quot;../Include/aspFile.asp?variable1=90&variable2=<%[red]=[/red]varValue%>&quot;


--Will Duty
wduty@radicalfringe.com

 
Hey Will,

Thanks, you're right; That was a syntax error in the way I posted it here. I still haven't found a way to get it to work, so for now I've just put the code from the include in each of the pages....
 
So the code works when it's not in an include?
--Will Duty
wduty@radicalfringe.com

 
What I mean by that is I dropped the code for the whole include page at the place in the page where I desire to just call it as an include, w/ FSO, etc. The advantage of that would be, since I need the same code on different pages, when I need to make changes I could just change it in one place. I need to know how to pass variables into this kind of page....
 
Did you read FroggerIII's reply to your post in:
query string for an include file
thread333-19772 Jon Hawkins
 
Thanks Jon,

FroggerIII's solution works great!!!!! What a creative idea, putting the code of the include file within a function, including the file and calling the function passing variables to it. Brilliant!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top