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

Call Function on another page

Status
Not open for further replies.

AndyApp

Programmer
Dec 20, 2001
259
GB
Hi,

I have a function called 'test()' on a page called 'worklogger.asp'. I need to be able to call this function from a different page called 'workloggersearch.asp' which has a function of it's own called by an onclick event.

Is this possible? MSDN said I have to expose the function as a method? How do I do this? "Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway" - Jim Davis (Garfield)
 
how about putting the function in an include file and then #including that file in every page that needs it Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
FesterSXS,

This may work but let me explain the problem a bit further. On the 2nd page (worklogger.asp) I have a number of textboxes, when the onclick event is fired on the first page (workloggersearch.asp) a recordset is generated from a DLL and placed into a variable then the text boxes (in worklogger.asp) are populated. I want to move the search option onto a seperate page to increase speed and this is the problem.

The textboxes aren't on the first page so obviously it errors, if the function is moved to the second page and someone visits that without searching, which they can do, it errors because there is nothing in the recordset OR I can't call the function because I don't know how.

Does this help any? (probably not!) "Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway" - Jim Davis (Garfield)
 
I don't know what you meant by the second post, but if you want to put a function in more than one ASP file, you simply make it a separate file and include it with a SSI. Shouldn't be any problems. -Phil
fillup07@hotmail.com
 
ok let me put it another way. If i put it in another file and use SSI's I need that SSI to ONLY be called if the user has done a search on another page and not just gone straight to the page that would display the results. "Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway" - Jim Davis (Garfield)
 
You can create a session variable on the first page and check it on the second page. I'm not sure if this is exactly what you're looking for but it will solve the problem.

So, on the first page do this:
Session("First_Page") = "true"

Now on the second page check the variable and if the variable is not set to true then Redirect the user back to the first page and set the session variable to false like this:
IF Session(&quot;First_Page&quot;) <> &quot;true&quot; THEN Session(&quot;First_Page&quot;) = &quot;false&quot;
Response.Redirect &quot;first_page.asp&quot;
END IF

You'll want to put the IF statement at the top of your page.

Hope this helps
 
If the second page can only be accessed if the user has submited the form, this just put a hidden field in the form like this:

<input type=&quot;hidden&quot; name=&quot;submitform&quot; value=&quot;true&quot;>

then on the second page check and see if they submited the form, if not you can redirect them back..

Code:
<%
 If Request.Form(&quot;submitform&quot;) <> &quot;true&quot; then
   Response.Redirect &quot;first_page.asp&quot;
 End if
%>
www.vzio.com
ASP WEB DEVELOPMENT



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top