||Short answers: You can't, you can't, you can't.|
Think about this for a moment: You are running your ASP code on a Server machine in Lower Franconia, South Texas. Your user is in an airplane flying over Zurich, Switzerland.
Question: What connection is there between your ASP code and the scripts in the browser?
You use ASP to create an HTML page that gets sent to the browser. And once that page is created, there is no longer any connection between the browser and the web server! The web server has completely forgotten that the browser ever made an HTTP request and that it answered that request by sending back some HTML.
More than that: The browser has completely forgotten the details of the request! Once it receives the HTML, it is satisfied that the HTTP request is finished.
Nothing in the HTTP request-response protocol expects to or is expected to maintain a connection once the request is answered!
If you do not understand these concepts, then you really need to get a good book on ASP and HTML and carefully read all the sections on "how ASP works" (or whatever those parts of the book are called). And if your book doesn't explain this really well and in careful detail, find another book.
In the meantime, you might want to look at these on-line resources (and feel free to suggest additions to this list! you can email me at Bill@ClearviewDesign.com):
Other FAQs in the ASPFAQs
How do I send [information] from client-side [scripts] to server-side ASP?
How can I pop up a message from ASP?
Can I send my output to a different window or frame?
Articles on 4GuysFromRolla
ASP Basics: What's Happening Back There?
...please contribute your favorites...
Ellery Familia justifiably noted that I do not mention Remote Scripting in any of the above. And since others might have the same comments and concerns, I thought I should discuss this avenue of coding.
If you are not familiar with Remote Scripting, I urge you to visit http://msdn.microsoft.com/scripting and click on Remote Scripting and read all about it.
In essence, Remote Scripting allows you to use a client-side component (this one happens to be written in Java, presumably so that it can be used with browsers other than MSIE) to request the results of a call to a specific function on a specific page from the server. Unlike XMLHTTP which can request any page from any site, thanks in part to the security limitations of Java, this component can only retrieve pages from the site that served up the original page. There are further restrictions, but read about them on the MSDN site.
I would like to emphasize that this is not an ability to simply and directly call a server side function. You must put some arcane code into your client-side script to make the call. It's not overly difficult code, but neither is it a direct and simple function call mechanism.
Also, you can't use Remote Scripting to call a server-side component that returns any kind of object (the most common request being for an ADODB.RecordSet).
None of that means that Remote Scripting is not useful! Just that it is not as simple to use as the questions given as the topic of this FAQ would seem to require.
Interestingly, you can accomplish effectively this same thing without using Remote Scripting. Simply use a <FRAMESET> and make one of the frames invisible (by allocating it 0% space in the window). Then you can invoke an ASP page into that invisible frame from another frame via
parent.invisibleFrame.location.href = 'xyz.asp?fld1=779&fld2=bananas';
Still, this scheme, too, does not answer the simple request of the questions presented by this FAQ: You still can't simply and directly call a server-side function from client-side code. Or vice versa.