?
Solved

Remote Scripting

Posted on 2003-03-12
18
Medium Priority
?
686 Views
Last Modified: 2012-05-04
I came across this article and tried it but it doesnt seem to work for me.
http://msdn.microsoft.com/library/en-us/dnserv/html/server042699.asp?fname=true
Any help will be appreciated.
Thanks
0
Comment
Question by:farzinm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 9
18 Comments
 
LVL 1

Expert Comment

by:DaDMan
ID: 8124576
Haaa... this good remote scripting... :-)
What problem do you encounter first of all?

Are you using Netscape or IE?
Do you have Norton on your pc? If so, does the script blocking is set to OFF? It must be.

Describe the problems you have.

Cheers
0
 
LVL 4

Author Comment

by:farzinm
ID: 8124833
I will the first thing tommorrow morning ..dont have access to my files right now thanks!
0
 
LVL 4

Author Comment

by:farzinm
ID: 8127901
I am using IE but tried by code on Netscape too doesnt work on either browser
I dont get any errors (in IE)
in Netscape my browser stops responding
Occasionally I get this error (in IE) "Object expected" at this line
this.rsapplet.startRequest(request.id,url_context,url,this.REQUEST_MODE_COMPLETE);

this is a part of the following function
function _MSRS_startRequest(url,method,args,cb,ecb,context)
I appreciate ur time
Thanks
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:farzinm
ID: 8128838
Yes I do have Norton on my PC
>> If so, does the script blocking is set to OFF >>

what does that mean?
0
 
LVL 1

Expert Comment

by:DaDMan
ID: 8129087
Hi farzinm,
  I doubt that remote scripting works on Netscape. I do not know exactly witch version it is working on Netscape but each time I've done some work with Remote scripting and Netscape was involve It had never work out. So in my mind Remote Scripting and Netscape was a combination to forget.

Second for the Norton blocking script, you have to open Norton and check the option. One of them is "Script Blocking" or something like that. This option has to be disable or turn off or else the remote scripting  wont work.

Now for your code, post your code, I would need your calling page(the one who call the remote scripting function) and your function. No need to have the _scriptLibrary files, only YOUR code. I will try to run it here and find the error.

Welcome to the wonderfull world of remote scripting! :-)
It maybe seem complex at the begining but very simple and very powerfull/helpfull on certain task. But you really have to bother with Netscape compatibility...

Post your code.

Cheers
0
 
LVL 4

Author Comment

by:farzinm
ID: 8129188
Well I am just learning so it doesnt really matter to me if this doesnt work in Netscape as long as I can work it on IE

RSClient.htm
<HTML>
<HEAD>
<TITLE>Servin' It Up with Remote Scripting</TITLE>
<BODY onload="refresh_list()">

<SCRIPT Language="JavaScript" src="../_ScriptLibrary/rs.htm">
</SCRIPT>
<H2>Address Book Sample</H2>

<FORM id=form1 name=form1>
 <INPUT type="text" size="50" id=Myname name=MyName onkeyup=refresh_list()><br>
 <SELECT id=NameList name=NameList size=10>
- One Moment Please ----------------------------------------------------------------------
</SELECT>
</FORM>
<SCRIPT LANGUAGE=javascript>
<!--
RSEnableRemoteScripting("../_ScriptLibrary")

function refresh_list()
{
 var serverURL = "server.asp"; /* Filename of our server-side script */
 var DisplayLength = 10   /* Maxinum number of records to return */
 document.form1.NameList.length = 0
 document.form1.NameList.length = DisplayLength
  var inValue = document.form1.MyName.value;
  var myVar = RSExecute(serverURL, "myFunction", inValue, DisplayLength);
  var myArray = myVar.return_value.split(":");
  for (i = 0; i < 10; i++)
  {
    var myOpt = new Option
    myOpt.value = myArray[i];
    myOpt.text  = myArray[i];
    if (i < myArray.length)
    {
      document.form1.NameList.options[i] = myOpt;
    }
  }
  document.form1.NameList.options[0].selected = true;
 }
//-->
</SCRIPT>
</BODY>
</HTML>

This is the asp file
server.asp
<%@ LANGUAGE=VBSCRIPT %>
<!--#include file="_ScriptLibrary/rs.asp"-->
<% RSDispatch %>

<SCRIPT Language=JavaScript RUNAT=SERVER>
 function Description()
 {
  this.myFunction = myFunction;
 }
 public_description = new Description();

function myFunction(strInput, numLength)
    {

   var objConn = Server.CreateObject("ADODB.Connection");
  objConn.Open("dsn=test;uid=test;pwd=test");
      var objRS = Server.CreateObject("ADODB.Recordset");
      objRS.MaxRecords = numLength;

      objRS.Open("SELECT lname, fname FROM Authors Where (lname + ', ' + fname) >= '" + strInput + "' ORDER BY lname, fname", objConn, 0, 3);

      var tmpMsg = new String;
      tmpMsg.value = "";

    while (!objRS.EOF)
      {
        tmpMsg.value = tmpMsg.value + objRS("lname") + ", " + objRS("fname") + ":";

        objRS.MoveNext();
      }
     objConn.Close();
         
      return tmpMsg.value;
    }
</SCRIPT>

Am using MYSQL as my backend. I am sorry I may sound dumb but I couldnt find the "Script Blocking" option.
I am sure by the end of this I will learn something thanks to u!
0
 
LVL 1

Expert Comment

by:DaDMan
ID: 8129340
How to disable script blocking in Norton AntiVirus 2002 or 2003 ; http://service1.symantec.com/SUPPORT/nav.nsf/docid/2001082912274906

How to disable Script Blocking in Norton AntiVirus 2001 ;
http://service1.symantec.com/SUPPORT/nav.nsf/docid/2001031311101006

A bit more information;
http://service4.symantec.com/SUPPORT/nav.nsf/aab56492973adccd8825694500552355/fa999a879aac3b2f88256b450071c66e?OpenDocument

For the remote scripting thing if it's only to learn I will post you one example during the day. It's hard to know what's the problem exactly with this one...

Cheers
0
 
LVL 4

Author Comment

by:farzinm
ID: 8139807
Can you post me a working example ?
Thanks
0
 
LVL 1

Expert Comment

by:DaDMan
ID: 8140056
Hi farzinm,
   Sorry bout the delay, I had a work rush. I'll do you simple example with some hardcoded value (simulating values from the db). I'll post it. I'll have it done by tomorow as am still stuck here.

Did you finally found the remote scripting blocking option from Norton?

And seem's that you still have the problem but the scripting must be off.

I'll get back to you. Sorry for this delay
Cheers.
0
 
LVL 4

Author Comment

by:farzinm
ID: 8140772
Yeah u guessed it right..I think I dont have the right to do it :( for its a corporate edition.
Also from what I read I think it is risky too to turn scripting on right?
0
 
LVL 1

Expert Comment

by:DaDMan
ID: 8143492
Hi farzinm,
   Here is a working example I just did. This example is working very good so if it is not working for you, than the problem is else where than in the code. Maybe other settings.



You will have to create a Access database with one table;
database name = car.mdb
Table name = tblCar
Field = Manufacturer (type=text)
Fiedl = Model (type=text)
index = idxMan on field manufacturer in asc order.

Once create you could put those value in it

Manufacturer      Model
Dodge           Dakota
Dodge              Durango
Dodge              Stratus
Dodge              Caravan
Ford              Mustang
Ford              Festiva
Ford              Taurus
Ford              Blazer
Honda              Accord
Honda              Civic
Honda              Prelude
Honda              Tracker

once you have this done, I suppose here that you have the _ScriptLibrary folder in the wwwroot folder. And of course in this folder you must have the rs.asp,rsproxy.class and rs.htm.

so here is the 2 page that you could copy past. You must save those page in wwwroot folder.


===========================================================
this page is call remexample.asp
===========================================================
<% @ Language=VBScript %>
<html>
<title>Remote scripting example</title>
<head>
<!-- Next two lines are to initiate and enable remote scripting -->
<script language="JavaScript" src="_scriptlibrary/rs.htm"></script>
<script language="JavaScript">RSEnableRemoteScripting("_scriptlibrary");</script>
</head>


<table border="0" cellpadding="1" align="center">
   <tr><td width="50%">
      <PRE><CENTER><B><FONT SIZE="" COLOR="navy">Select a Manufacturer</FONT></B></CENTER></PRE>
<table border="0" cellpadding="1" align="center">
      <tr>
        <td valign="top"><B>Manufacturer</B></td>
        <td align="left" valign="top">
            <select name="manufac" ID="manufac" size=1 onChange="RefreshList()">
            <option selected>&nbsp;-Manufacturer-&nbsp;</option>
                     <option value="Ford">Ford</option>
                     <option value="Dodge">Dodge</option>                  
                     <option value="Honda">Honda</option>
        </select>*
      </td>
      </TR>
      <tr>
            <td valign="top"><B>Make = </B></td>
              <td>
            <select name="make" ID="make" size=1>
            <option selected>&nbsp;- Make -&nbsp;</option>
        </select>
       </td>

      </tr>
</table>
</TR>
</table>


<script language=VBScript>
'The name of the page containing the remote scripting functions
strDBPage = "rsfilter.asp"

'This sub is call when you select a manufacturer. It call the remote script function
'and return the values inside the make list box
sub RefreshList
    'Set an object instance of manufactuer list box
      set objManufac = document.all("manufac")
      'set an object instance of make list box
      set objMake    = document.all("make")

    'clear the make list box
      while objMake.length > 0
        objMake.remove (0)
    wend
      
      'Call the remote-script function
      'RsExecute pass those param; Function to be execute-> first value
    set objRS = RSExecute(strDBPage ,"GetMake", objManufac.value)
    sRS = objRS.return_value
    aRows = Split(sRS, Chr(13))

    if sRS = "" then
         'no result returned
      else
        for i = 0 to UBound(aRows) - 1
          aFields = Split(aRows(i), ";")
          set objOption = document.createElement ("OPTION")
          objOption.Value = aFields(0)
          objOption.Text = aFields(0)
          objMake.add objOption
      next
    end if
end sub

</script>
</html>

==========================================================



==========================================================
This page is the one that contains the remote functions.
name this page = rsfilter.asp
==========================================================
<%@ LANGUAGE=VBSCRIPT %>
<%
strconn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & server.mappath("car.mdb") & ";"
%>
<% RSDispatch %>
<!--#INCLUDE FILE="_ScriptLibrary/rs.asp"-->
<SCRIPT RUNAT=SERVER Language=javascript>
    function Description()
    {
          this.GetMake = Function('IDManufac', 'return GetMake(IDManufac)' );
    }
    public_description = new Description();
</script>

<SCRIPT RUNAT=SERVER Language=VBScript>
   
   function GetMake(IDManufac)
      set objRS = createobject("ADODB.Recordset")
        Sql = "SELECT Model FROM tblCar WHERE Manufacturer = '" & IDManufac & "'"
        objRS.Open Sql,strconn
        if not objRS.EOF then
        GetMake = objRS.GetString(, , ";")
      end if
        objRS.Close
      set objRS.ActiveConnection = nothing
      set objRS = nothing
   end function
   
</SCRIPT>
==========================================================


So here you go. Of course you could do (once you get the idea) a lot of combination and diference. For example you could have has many list box depending as you want.

You could do a sort of intelligent search where lets say in a text box, on the third digit entered (trigger by the keyup event) you call a remote function to auto populate a list with matching value. Example you want to have a search text box, when user enter lets says "Dod" then you autopopulate all record that match "Dod" in your db and so on. A sort of auto-filtering.

Anyway, when you'll get to know how it works you'll find this very very powerfull and helpfull. But Once again , beware of compatibility issue.


Let me know if you have some questions.

Cheers
0
 
LVL 1

Expert Comment

by:DaDMan
ID: 8143509
Hi there,
   Just another advise, since it's hard with remote scripting to know what error exactly the page have when it's not working, because it wont output to error on the html page like normally, you simply have to turn on the script debugging option in your IIS administration panel. With this feature on, you will get to know exactly the problem inside the remote script page.


Cheers
0
 
LVL 1

Accepted Solution

by:
DaDMan earned 200 total points
ID: 8143547
Ho.. and I forgot this also...
"Also from what I read I think it is risky too to turn scripting on right?"

Well this is only MY point of view and does not mean this it's the RIGHT one.

I first of all do not have Norton... as I always had along the way some searching and searching and searching on an in some code, to finally find out that it's a option in Norton that makes things go wrong...I kind of got sick of this as it's not only in ASP/IIS but different language and other soft that are not running properly due to some specific option in Norton... So the time spent to find out that the problem is in fact Norton, well it's a big waste of energy and a waste of time. So I have AVG anti-virus now and man, everything is just fine....

So this said. Turning scripting off in my opinion is nothing there. But this is simply my humble opinion. One thing thought, is that if your norton blocking scripting thing is ON than forget about remote scripting. But anyway, in reality this is suppose to be on a web server to be run and I seriously doubt that on anyweb server that host asp application they have the norton blocking scripting on. I never had this problem. So of course on you local pc you could turn it off while your testing your things and put it back on after if you want. On your host web server you wont have any problems.

Cheers
0
 
LVL 4

Author Comment

by:farzinm
ID: 8144769
Hi DaDMan
Thanks for all your help. Havent tried your code but will do so on Monday and get back to you.
0
 
LVL 1

Expert Comment

by:DaDMan
ID: 8145547
Ok, let me know how it works.

Cheers
0
 
LVL 4

Author Comment

by:farzinm
ID: 8155206
You are a genius. It works! thanks a lot
0
 
LVL 4

Author Comment

by:farzinm
ID: 8155360
This is a bit strange..the above code that I posted seems to work now..earlier I had the files in a folder and now I have them in the root directory of my project file..strange. I think I might have missed out something earlier.
0
 
LVL 1

Expert Comment

by:DaDMan
ID: 8156755
Well maybe only the problem was your dsn less string path...

Well am happy that everything works out good for you now and you'll find remote scripting very very interesting.


Cheers
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question