How To Use Client-Side VBScript with Remote Scripting

Summary

You can use client-side VBScript with remote scripting, but you may face limitations, such as limited cross-platform compatibility and call capability. Also, you may not be able to call server-side Active Server Pages (ASP) methods asynchronously using the RSExecute method or use the RSGetASPObject methods when you use client-side VBScript.


When you use client-side VBScript, your remote scripting application works with Internet Explorer version 4.01 or later. It may also work with Netscape with a VBScript plug-in.

More Information

This article relies on the remote scripting samples, which are available from the following Microsoft Web site:
In the left pane, click Remote Scripting, and then click Samples. You can then download the sample that is appropriate for the processor on your Web server. By default, the remote scripting sample will be installed in the C:\InetPub\Wwwroot\ folder. The samples include the _ScriptLibrary, which creates the _ScriptLibrary subdirectory under C:\InetPub\Wwwroot\. Within the _ScriptLibrary directory is another subdirectory named Samples, which contains the Simple.htm file.

First, make a copy of Simple.htm, and name it SimpleVBS.htm.


Using a Web page editor such as Visual InterDev, edit SimpleVBS.htm. First, delete the third SCRIPT tag and all of its contents, as shown below:
<SCRIPT LANGUAGE="javascript">

var serverURL = "simple.asp";
var aspObject;

function myCallBack(co)
{
alert("CALLBACK\n\n" +
"status = " + co.status + "\n\n" +
"message = " + co.message + "\n\n" +
"context = " + co.context + "\n\n" +
"data = " + co.data + "\n\n" +
"return_value = " + co.return_value);
}

function errorCallBack(co)
{
alert("ERROR_CALLBACK\n\n" +
"status = " + co.status + "\n\n" +
"message = " + co.message + "\n\n" +
"context = " + co.context + "\n\n" +
"data = " + co.data);
}

function handleRSExecute()
{
var co = RSExecute(serverURL,"Method1");
myCallBack(co);
}

function handleRSExecuteAsync()
{
RSExecute(serverURL,"Method1",myCallBack,"RSExecute");
}

function handleRSGetAspObject()
{
aspObject = RSGetASPObject(serverURL);
var msg = "aspObject public_description\n";
for (name in aspObject)
msg += " " + name + "\n";
alert(msg);
}

function handleAspObject()
{
aspObject = RSGetASPObject(serverURL);
aspObject.Method2(myCallBack,errorCallBack,"aspObject");
}

function handleInvalidCall()
{
var co = RSExecute(serverURL,"Method3",myCallBack,errorCallBack,"Invalid RSExecute");
}

</SCRIPT>
Also, remove the following INPUT tags:
<br><br><input type=button name=btnRSExecuteAsynch value="RSExecute Method1 (async)" onclick="handleRSExecuteAsync()" style="width:250;height:25">
<br><br><input type=button name=btnRSGetASPObject value="aspObject = RSGetASPObject" onclick="handleRSGetAspObject()" style="width:250;height:25">
<br><br><input type=button name=btnASPObject value="aspObject.Method2 (async)" onclick="handleAspObject()" style="width:250;height:25">
<br><br><input type=button name=btnInvalidCall value="RSExecute Invalid Method3" onclick="handleInvalidCall()" style="width:250;height:25">
NOTE: Do not delete the first two SCRIPT tags, reproduced as follows, which are required for remote scripting:
<SCRIPT LANGUAGE="javascript" src="../rs.htm></SCRIPT>
<SCRIPT LANGUAGE="javascript">RSEnableRemoteScripting("..");</SCRIPT>
Then, add the following VBScript:
<SCRIPT LANGUAGE="VBScript">

serverURL = "simple.asp"

function handleRSExecute

set co = RSExecute(serverURL,"Method1")
msgbox("CALLBACK" & CHR(13) & CHR(13)_
& "status = " & co.status & CHR(13) & CHR(13)_
& "message = " & co.message & CHR(13) & CHR(13)_
& "context = " & co.context & CHR(13) & CHR(13)_
& "data = " & co.data & CHR(13) & CHR(13)_
& "return_value = " & co.return_value)
set co = nothing

end function

</SCRIPT>
<script language="JavaScript" src="../rs.htm"></script>
<script language="JavaScript">RSEnableRemoteScripting("..");</script>
NOTE: It is important that you add the SCRIPT LANGUAGE="VBScript" before the first two script language="JavaScript" tags. If not, you may encounter errors.

NOTE: When you view SimpleVBS.htm in your browser and click RSExecute Method1, you should get a status = 0. If not, check to ensure that the address in your browser is a URL and not the physical file location on the Web server.

References

For more information about remote scripting, please see the following Microsoft Web site:
Propriétés

ID d'article : 229661 - Dernière mise à jour : 14 août 2008 - Révision : 1

Commentaires