Calling an ASP function from an external ASP file

aspvbscriptwebsite

For some reason, I can include an ASP file with the following code:

<!--# include virtual="/includes/func.asp" -->

But, I have some functions in that file, and I can't call them into my main file. Can someone help? I'm calling them like this:

<% my_func() %>

..and all I get is an error message, with a link to another webpage. Thanks for your help in advance.

Best Answer

In VBScript, you can call functions in a handful of ways;

  1. returnval = functionYaddaYaddaYadda()

  2. functionFoo()

  3. Call functionBar()

You're essentially trying to #2 with shorthand ASP tags. Use:

<%= my_func() %> 

The "=" is the shorthand way of doing:

response.write(my_func()) 

P.S. Check out the MSDN VBScript Reference. There's really not much to VBScript outside of this reference manual. Maybe more elegant tricks but the meat of VBScript can be found on that site.

Related Topic