Connecting Tech Pros Worldwide Help | Site Map

How to include file using vbscript

Soniad's Avatar
Newbie
 
Join Date: Jan 2009
Location: Mumbai
Posts: 31
#1: Feb 16 '09
Hello,

I want to include asp file within vbscript, this file name i am taking in variable .
and when i use this variable in the include tag outside delimiters(<%%>), it does not work,
Expand|Select|Wrap|Line Numbers
  1. <%Dim AllocPath
  2. AllocPath = "SchemeAllocation/"&Trim(lcase(ProductName))&"/QuotaAlloc.asp"
  3.                 %>
  4.  
  5. <!-- #include file=<%=AllocPath %>--> 
  6.  
  7.  
if i give the file name directly, then it works .
Expand|Select|Wrap|Line Numbers
  1. <!-- #include file="SchemeAllocation/mobilephones/QuotaAlloc.asp"--> 
  2.  
how to include this page using vbscript or without,such that the code inside this page should execute.

also , it shud take care that , some of the variables which are used in the parent page (including page) are accessed/used directly in child (included page).


Regards,
"D"
sashi's Avatar
Expert
 
Join Date: Jun 2006
Location: Seremban, Malaysia
Posts: 1,630
#2: Feb 16 '09

re: How to include file using vbscript


I don't see any major differences in the 1st code segment & the 2nd code segment. Why do you need to assign the path details to a string type variable (AllocPath) when you can assign the path details straight the "#include" directive?

What are the scope of the variables? If you need to reuse a variable then you should make it public and not private.

Avoid using to many variables as it's will create load at server side.
Soniad's Avatar
Newbie
 
Join Date: Jan 2009
Location: Mumbai
Posts: 31
#3: Feb 17 '09

re: How to include file using vbscript


Quote:

Originally Posted by sashi View Post

I don't see any major differences in the 1st code segment & the 2nd code segment. Why do you need to assign the path details to a string type variable (AllocPath) when you can assign the path details straight the "#include" directive?

What are the scope of the variables? If you need to reuse a variable then you should make it public and not private.

Avoid using to many variables as it's will create load at server side.

The productName varies. and i have created different folders for different products.as it is necessary, coz,if any new product is added then no need to change in the code by hardcoding path to access files under different products, thats y i am taking the path in variable.

Regards,
"D"
sashi's Avatar
Expert
 
Join Date: Jun 2006
Location: Seremban, Malaysia
Posts: 1,630
#4: Feb 17 '09

re: How to include file using vbscript


Look at more dynamic approach, why not store the product details. i.e. name, code & supplier in the database.

Using MS Access as a starter would be a better choice. Good luck.
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#5: Feb 17 '09

re: How to include file using vbscript


Sashi is right, but I'm not sure his explanation is clear. There is a problem using a vbscript variable in an include file declaration because the include is fired BEFORE the vbscript is read. The major reason for doing it this way is so you can put common subroutines and functions in an include file, include it at the top of the page, and call those functions as you go. Does this make sense?

Of course if you want to include straight HTML or CSS code into your ASP page, there is no reason to use a Server-side include. The only time I would prefer to use an include is to add common subroutines. I believe you will need to rethink how you are going to work your page, feel free to ask for more pointers if needed.

Jared
Soniad's Avatar
Newbie
 
Join Date: Jan 2009
Location: Mumbai
Posts: 31
#6: Feb 25 '09

re: How to include file using vbscript


Hello,


I used another way, as variables not working or used in include tag ,
and i am calling pages according to the productnames, also i needed to execute the code in the calling page in the background.
I used ajax . in this i can call and execute pages depending on the productname.


Regards,
"D"
Reply