Library tutorials & articles
Remote Scripting Made Easy
- Introduction
- Client-side scripting
- Server-Side Requirements
Server-Side Requirements
The server side of the remote scripting is a little less cryptic. And, once you have successfully put the pieces together, incredibly repeatable. Below is a sample ASP page that would be called from the ExecuteRS function described in the previous section.
<% RSDispatch %>
<!--#INCLUDE FILE="_ScriptLibrary/rs.asp"-->
<SCRIPT RUNAT=SERVER LANGUAGE="JavaScript">
function MyServerMethods()
{
this.TestRS = Function( 'parameter','return TestRS(parameter)'
);
}
public_description = new MyServerMethods();
</SCRIPT>
<SCRIPT RUNAT=SERVER LANGUAGE="VBScript">
'-----
Function TestRS(sParm)
TestRS = "Here I am - " & sParm
End Function
</SCRIPT>
The important elements of this sample are that the RSDispatch call
and the #INCLUDE statement. The RSDispatch function
(it is implemented in the rs.asp code) must be made as the first VBScript statement.
Also, make sure that the #INCLUDE uses FILE, not VIRTUAL
and that the statement itself is not imbedded in another <SCRIPT>
block. This is a significant change from Windows NT where neither of these restrictions
caused remote scripting to fail. In Windows 2000, they do.
The functions that are available to be called from the client side are listed
in the MyServerMethods function. The first parameter(s) to the Function call
represent the number of parameters that are being called from the client side.
The last parameter is, in essence, the VBScript command that will be executed
in order to generate the return value. For example, if the incoming call had
three parameters, the Function call would look like Function('parm1', 'parm2', 'parm3', 'return CallName(parm1, parm2, parm3)')
Also, the name of the parameters that you provide in the Function call are
matched up to the parameter list that are in the call prototype (the last parameter).
Once you have the structure in place, the code that gets executed in the function
is standard VBScript. You have just as much flexibility as you would in a normal
ASP page. And whatever value is assigned to the function will be sent back to
the calling page in the return_value property of the 'co'
object.
One of the trickier aspects to using remote scripting is debugging. If something goes wrong between the client and server side, it is difficult to trace the ultimate source of the problem. What I have taken to doing is to start by making sure that the connection works from the client side. Using the sample server-side code that I have provided, you should be able to implement a bare bones remote scripting function. That will let you determine whether a connection is being made to the server and a response received correctly. If there is a problem with this process, it is usually a type in the URL (it should include the http:// header) or a syntax error in the server-side ASP. Once that basic functionality has been confirmed, you can use the IIS log file to help with any errors that are generated on the server side. In my experience, any run-time error message can be found in place of the URL that is being called.
Related articles
Related discussion
-
.NET Developer in Ghana Required....
by sysview (0 replies)
-
Problem when using TemplateField and ImageButton
by ashiquemca (15 replies)
-
problem with special characters
by avlisodraude (1 replies)
-
PrintDocument printing using DOS print
by squrrel (1 replies)
-
Web App Service Project - Assistance Requested
by JusticeV (0 replies)
Related podcasts
-
jQuery in ASP.NET
In this episode Chris Brandsma, Rick Strahl, Dave Ward, Bertrand Le Roy, Scott Koon, and Steven Harman discuss Microsoft's jQuery in ASP.NET announcement.This episode of the Alt.NET Podcast is brought to you by LLBLGen Pro, the most mature O/R mapper and code generator out there.Are you loo...
Events coming up
-
Nov
20
Full Frontal JavaScript Conference
Brighton, United Kingdom
A one day JavaScript conference held in Brighton, UK whose essence is to discuss JavaScript "with nothing concealed or held back".The conference is being held at one of the world's first cinemas, which first opened in 1910.Speakers include...
Thats what drives me nuts about AJAX - its the wrong way to do 90 percent of what people are freaking out over and getting so hyper whatevered over.
http://sportsforum.ws - chat room on top (use IE - chat stuff doesnt need it - if I make a blank white page with nothing on it - it doenst work in Moz cause I made it)
The typing part is sort of hidden under the chat, when your curser is on the bottom of that little chat area you can see it change to like pull down type - pull down
Just script - no refresh - no xmlhttp - no security issues - works (if written by someone else
My scripts probably look like crap, cause I am throwing them up, and on to the next - but they work - and in the case of the chat - I wrote that over two years ago - and still nobody picks up and uses that simple little method.
You mention a "ZIP file in the resources section on the right" with the relevant files but I could not find it. This is a very interesting article and would like to try it out.
Also is it possible to use the same technique but haveing the calls to the remote scripts from a script which is being processed on the server (i.e. an asp page on the server calling a remote script on the same server or a remote server)
Thanks
This thread is for discussions of Remote Scripting Made Easy.