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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to call a function from another ASP page?

Status
Not open for further replies.

jsteph

Technical User
Oct 24, 2002
2,562
US
Hi all,
Without using the <#Include> tag, is there a way to call a function in one asp page from another?

Using the Include is problematic for me because these functions may also be called 'standalone'--ie. if I use this asp page as a source for an iFrame. Yet I don't want to have to duplicate coding so I want to call some of these functions from other pages.

But when I have DIM statements in one page if it's <include>ed in another I get the "Name Redefined" error because I'm pretty standardized about variable naming so this would be expected. I'm just wondering if there's another way around it. Also I get error on the Option Explicit statement used twice.
Thanks for any help,
--Jim
 
Sounds like a job for modular / object programming. ;)

Other than an #include, I couldn't think of a way to do that....



Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg
 
Gbaughma,
Thanks...i was afraid of that...I know that's the right way to do it but I've got to get this out the door today. I'm going to just copy the code, until I get time (likely never) to change it,
--Jim
 
jsteph, I don't use VB when coding ASP (as I assume you do - most ppl do), so the best I can offer is a JScript example. However, I'm sure it's just as easily done in VB.

You can include a script file in your ASP page (server side) by using the runat="server" attribute in the script tag:

Code:
<%@ LANGUAGE="JavaScript" %>
<script language="javascript" type="text/javascript" src="test.js" [!]runat="server"[/!]></script>

<%

[gray][i]//A function defined in the script file:[/i][/gray]
a();

%>

Code:
function a() {
   Response.Write("blah");
}

-kaht

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top