HOWTO: Use Client-Side VBScript with Remote Scripting
ID: Q229661
|
The information in this article applies to:
-
Active Server Pages
-
Microsoft Internet Explorer (Programming) versions 4.01 SP1, 5.0
-
Microsoft Internet Information Server versions 4.0, 5.0
SUMMARY
You can use client-side VBScript with remote scripting, but you might 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 using client-side VBScript.
When using client-side VBScript, your remote scripting application will work 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 available at http://msdn.microsoft.com/scripting/. Select Remote Scripting, then Samples, and download the sample appropriate for the processor on your Web server. By default, the remote scripting sample will be installed in C:\InetPub\Wwwroot\. The sample will include the _ScriptLibrary, which will create the _ScriptLibrary subdirectory under C:\InetPub\Wwwroot\. Within the _ScriptLibrary directory, there will be another subdirectory called Samples, which will contain the file Simple.htm.
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 its contents, 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 here, which are required for remote scripting.<SCRIPT LANGUAGE="javascript" src="../rs.htm></SCRIPT>
<SCRIPT LANGUAGE="javascript">RSEnableRemoteScripting("..");</SCRIPT>
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="../_ScriptLibrary/rs.htm"></script>
<script language="JavaScript">RSEnableRemoteScripting("../_ScriptLibrary");</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 with a browser and click on the RSExecute Method1 button, you should get a status = 0. If not, check to ensure that address in your browser is an 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:
http://msdn.microsoft.com/scripting/
Additional query words:
kbASP kbGrpASP
Keywords : kbASP kbRemote kbScript kbGrpASP kbIE401sp1 kbIE500 kbCodeSnippet kbiis400 kbiis500
Version : WINDOWS:4.01 SP1,5.0; winnt:4.0
Platform : WINDOWS winnt
Issue type : kbhowto