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

Calling a subroutine from a button 2

Status
Not open for further replies.

TimPro

Programmer
Feb 26, 2002
8
IE
i know this is only a small problem, but i am new to asp.
i tried to call the sub using the onClick method of the button, but nothing happened.

how is it done, please.
Thanks
Tim
 
Tim, I have replied to this, but tek-tips seems to have made a new thread of it!

See Two scraps of code...

Regards
Griff
[smile]
 
I can't find this person's reply to your message....so i'll answer you.

Since ASP code is executed on the server, and it gets processed and stripped out before it sends the results to the client....you cannot have a client-side event call an ASP function.

You could emulate this by including a querystring variable that would execute the sub if its turned on, and then have ther button reload the page with the sub routine executing. So you could make the button call this link:

mypage.asp?CallRoutine=1

and then in your mypage.asp put this code:

<%
If request.querystring(&quot;CallRoutine&quot;) = 1 then
MyRoutine
End if
%>

Not the most elegant way to do something, depending on what you're doing, it might be better to use client-side scripts.
 
Jeremy / Tim,

I thought the query related to something like simple field validation at the client side - rather than getting the client to ask the server to perform something... Tim,
what is it you're after?

My original reply to your query has gone way down the board, so I'll repost it here in a moment!

Have a good one
Griff
[smile]
 
Tim,
below are two scraps of code for a button.
With javascript (I've assumed you mean javascript for the client side) you must watch the case v. carefully.

This bit is the code to execute
[tt]
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>

function java_close_window(){
window.close();
}

</SCRIPT>
[/tt]
this defines the button
[tt]
<input type=&quot;button&quot; value=&quot;Yes&quot; onClick=&quot;java_close_window();&quot;>
[/tt]

Does this help?

Griff
[smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top