SunQuest
 
       Code Examples
  Home arrow Code Examples arrow Remote Scripting Example
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CODE EXAMPLES

Remote Scripting Example
By: aspfree
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 9
    2001-05-08

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    This example shows how to display a header-detail form using remote scripting. It gives us the chance to navigate through the records with next, previous, move first and move last.This example shows how to display a header-detail form using remote scripting. It gives us the chance to navigate through the records with next, previous, move first and move last.This method is particularly useful when we need to quickly scroll through a number of records. This example shows some basic navigation techniques but more functionality could be added by simply calling a different function from the client side to update or delete the current record.To see this example working please check www.houndware.com/dario/remote.aspThis is the client page. I used the pubs database to get each author and display every book written by her/ him.


    Client side ---Remote.asp

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

    <!--
    #include file = "../ADOVBS.INC"-->

     

    <HTML><HEAD>

    <
    TITLE>Remote Scripting Example</TITLE>

    <
    SCRIPT Language="JavaScript" src="../_ScriptLibrary/rs.htm"></SCRIPT>

    <!-- enable remote scripting -->

    <script language="JavaScript">RSEnableRemoteScripting("../_ScriptLibrary");</script>

    <script language="JavaScript">

    // declare variables

    var serverURL = "RemoteAction.asp";

    var intcount =0 ;

    var intLastTran =1 ;

     

    function firstTran()

    {

                intcount=1 ;

                getRemoteData (intcount );

    }

    function lastTran()

    {

                intcount= intLastTran;

                getRemoteData(intcount);

    }

    function previousTran()

    {

     

                if (intcount < 2 )

                {

                            alert ( "You have reached the begining ");

                }

                else

                {

                            intcount = intcount -1 ;

                            getRemoteData(intcount);

                }

    }

    function nextTran()

    {

                if ( intLastTran <= intcount )

                {         

                            alert ("You have reached the end ");

                }

                else

                {

                            intcount = intcount + 1;

                            getRemoteData(intcount);        

                }

    }

    function getRemoteData( intcount  )

    {

                status="Getting record...";

                // call server-side function with the page name , funcion and parameter

                // NOTE: if more parameters need to be passed, simply add them to the string

                // ie:      co=RSExecute(serverURL,"getRemoteData",param1,param2,param3,..);   

                co=RSExecute(serverURL,"getRemoteData",intcount);

                var row;

                var detail ;

                var trandata;

                var a ;

                var trandata = new Array() ;

                //          create an array with each row as an element

                row = co.return_value.split(";;");

               

                DataTran.innerText=""; // clear the previous value

     

                           

                detail = "<table  width=100% cellspacing=0><tr background=silver><td width=10% ><strong>Title ID</strong></td><td width=40% ><strong>Title</strong></td><td width=5% ><strong>Type</strong></td><td width=7% ><strong>Price</strong></td><td width=7% ><strong>Advance</strong></td>"; 

                for (var i=0; i <  row.length ; i++ )

                {         

     

                            col = row[i].concat();

                            col= col.split(";");

                            trandata[i]= new Array();

                            detail = detail +  "<tr>" ;                                  

                            for (var a=0 ;a <  col.length   ; a++)

                            {

     

                                        trandata[i][a]= col[a]; // setting the column value into the array

                                       

                                                    if ( a > 6 )

                                                    {

                                                                detail= detail +   "<td>"  + trandata[i][a] + "</td>" ;                                         

                                                    }

                                       

               

                            }

                            detail = detail +  "</TR>" ;                   

                                       

                }         

               

                DataTran.innerHTML =  detail  ;

                document.all.FirstName.value=trandata[0][0];

                document.all.LastName.value=trandata[0][1];

                document.all.Phone.value=trandata[0][2];

                document.all.City.value=trandata[0][3];

                document.all.State.value=trandata[0][4];          

                document.all.Zip.value=trandata[0][5]; 

                intLastTran = trandata[0][6];

                status="Done";

    }

    </script >

    </head>

    <body bgcolor="#c9cbc0" alink=white vlink=white>

    <table width=90% border=1 bgcolor=silver  bordercolordark=Black>

    <tr ><td colspan=10> <table bgcolor=336699 width=100%><tr><td width=75% ><font size=6 color=white >Remote Scripting Example </font><font color=white size=3> by  <a href=mail:dmedele@houndware.com> Dario Medele</a></font></td>

    <td>

                <a href="Javascript:lastTran()" > Last Record</a>

                <a href="Javascript:nextTran()" > Next Record</a>

                <a href="Javascript:previousTran()" >Previous Record </a>

                <a href="Javascript:firstTran()" >First Record </a>

    </td></tr></table>

    </td></tr>

    <tr><td colspan =10>

    <table width=100% cellspacing=0  bordercolordark="black">

    <tr ><td valign=bottom><strong>First Name</strong></td><td>

    <input type= text name=FirstName value="">  

    </td></tr>

    <tr ><td><strong>Last Name</strong></td><td>

    <input type= text name=LastName value="">   

    </td>

    </td></tr>

    <tr><td><strong>Phone</strong></td> <td>

    <input type= text name=Phone value="">          </td>

    </tr><tr><td><strong>City</strong></td><td>

    <input type = text name=City value="">

    </td></tr>

    <tr><td><strong>State</strong></td><td>

    <input type = text name=State value="">

    </td></tr>

    <tr><td><strong>Zip</strong></td><td>

    <input type = text name=Zip value="">

    </td></tr>

    </table>

    </td></tr>

    <tr><td colspan =10>

    <table width ="100%" border="1" bordercolordark="Black">

    <tr bgcolor=336699 ><td colspan=10> <table width=100%><tr><td width=50% ><font color=white ><strong>Titles</strong></font></td><td>

    </td></tr></table><tr><td colspan=10 >

    <DIV ID="Detail">

    <p ID="DataTran"></p>

    </DIV>

     </td></tr>

    </td></tr><tr><td>

    </td></tr></table>

    </BODY>

    </HTML>

     

    End of client side

     

     

     

     

     

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

    Server side  -- RemoteAction.asp

     

     

    <%@ LANGUAGE=VBSCRIPT %>

    <% RSDispatch %>

    <!--#include file = "../ADOVBS.INC"-->

    <!--#include file="../_ScriptLibrary/rs.asp"-->

    <html>

    <head>

    <title>SiS</title>

    <SCRIPT RUNAT=SERVER Language=javascript>

    function Description()

    {

                this.getRemoteData= Function('intcount','return getRemoteData(intcount)');

    }

                public_description = new Description();

    </SCRIPT>

    <SCRIPT RUNAT=SERVER Language=VBScript >

    function getRemoteData(intcount )

    // This sql string is made of the elements of the header, the total number of records in the header ,

    // and the details. Also the parameter passed (intcount) will indicate which record the client requested

                 

                strsql = " select a.au_fname, a.au_lname, a.phone, a.city , a.state,a.zip, (select count(*) from authors ) as total, isnull(t.title_id,'_')as title_id ,isnull(t.title,'_') as title "  &_

                " , isnull(t.type,'_') as type  ,isnull(convert(varchar(100),t.price),'_')as price ,isnull(convert(varchar(100),t.advance),'_') as advance "  &_

                " from authors a left " &_

                " join titleauthor ta on a.au_id = ta.au_id " &_

                " left join titles t on ta.title_id = t.title_id " &_

                " where a.au_id  in " &_

                " ( select top 1 au_id  from authors where au_id in ( select top " & intcount & "  au_id " &_

                " from authors order by au_fname asc ) order by au_fname desc ) " &_

                " order by au_fname asc "

               

               

                strconn = "Driver={SQL Server};Description=SIS;SERVER=111.111.111.111;UID=sa;PWD=;DATABASE=pubs"

               

                set rs= server.CreateObject("ADODB.Recordset")

               

                rs.Open strsql,strconn, adOpenStatic,adLockOptimistic

     

                if rs.eof and rs.bof then

                            strTemp= "No data found"

                else

                            // separate rows using ";;" and columns using  ";"

                           

                             strTemp =  rs.Getstring(,,";",";;")

                end if

                // asign the string to the function

               

                getRemoteData = strTemp

        rs.Close

        set rs.ActiveConnection = nothing

        set rs = nothing

    end function

    </script>

    </head>

    <body>

    </body>

    </html>

     

    end of server side


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Code Examples Articles
    More By aspfree

     

    IBM® developerWorks developerWorks - FREE Tools!


    Be the first to hear about i5/OS V6R1!

    Hold your calendar on January 30, 2008 for this free webcast on the new i5/OS. Rational's Enterprise Modernization products will be discussed at this webcast as they help to drive the application development environment for this new System i OS. <br />And learn how i5/OS will take you to the next step of efficient, resilient business processing. You will hear about the new i5/OS capabilities as it will be the most significant i5/OS release in years. If you cannot join the webcast on 1/30/08 you can still use this link to listen to the replay.<br />
    FREE! Go There Now!


    NEW! Best Practices: The Integrated Project and Portfolio Management Platform.

    Hear how IBM Rational Project and Portfolio Management integrated solutions help teams put the right tools and processes in place to maximize the effectiveness and efficiency of project teams and ensure that the business vision is being executed correctly. Learn how to automate and integrate requirements prioritization, top-down project planning, communications and controls, and methodology deployment to keep your scope, costs, and schedules under control. Tackle with an end-to-end approach the management of scope and scope changes, usage of methodology to control and empower project teams, and optimization of resources to align activity costs with the overall project plan.
    FREE! Go There Now!


    NEW! Develop Systems Software Assets with IBM Rational Asset Manager

    Join us for this on demand webcast to learn about developing complex systems more quickly and efficiently. We'll cover market drivers for developing, governing and reusing systems software assets and how you can develop system software assets with Rational Asset Manager.
    FREE! Go There Now!


    NEW! Download the free Web Application Security eKit

    Discover how IBM Rational AppScan Standard Edition can help you detext vulnerabilities in your web applications in the Web Application Security eKit. IBM Rational AppScan is a leading suite of automated web application security solutions that scan and test for common Web application vulnerabilities. The new Web Application Security eKit provides you with valuable resources, including white papers, demos, and additional information on the benefits of testing your Web applications.
    FREE! Go There Now!


    NEW! Evaluate Rational Host Access Transformation Services (HATS) Toolkit V7.1

    Visit IBM developerWorks to download a free trial of the Rational Host Access Transformation Services (HATS) Toolkit. The HATS toolkit provides a set of plug-ins for the IBM Rational Software Delivery Platform to help you easily extend your legacy applications. HATS makes your 3270 and 5250 applications available as HTML through the most popular Web browsers, while converting your host screens to a Web look and feel and it also enables you to develop new Web, portal, and rich-client applications.
    FREE! Go There Now!


    NEW! Integrating XML into Your Enterprise Using Data Federation

    XML has become a common way of storing business data as flat files and many data server vendors including IBM have provided ways to store this data within relational database systems. Increasingly collections of XML files are accessed like databases using an xQuery and other XML standard mechanisms. Businesses find the need to combine the traditional tabular structured data with XML formatted data. In this webcast, you’ll learn about IBM’s WebSphere Federation Server technology, which provides users with the ability to integrate these two data formats.
    FREE! Go There Now!


    NEW! Rational Modeling Extension for Microsoft.Net

    Rational Modeling Extension for Microsoft .NET enhances usability for code generation supporting a more intelligent refactoring. The latest enhancements enable organizations with Java and .NET systems and software development maintain architectural integrity across heterogeneous platforms.
    FREE! Go There Now!


    NEW! Rational Talks to You: Manage RUP-based CMMI initiatives

    Join this Rational Talks to You teleconference on December 4 at 1:00 pm ET to discuss how Rational Method Composer can help meet your compliance objectives. Get your questions answered!
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Functional Tester V7.0.1

    Get a free trial download of the latest version of IBM Rational Functional Tester V7.0.1. Rational Functional Tester is an automated functional and regression testing solution for QA teams concerned with the quality of their Java, Microsoft Visual Studio .NET, and Web-based applications.
    FREE! Go There Now!


    NEW! Try the IBM SOA Sandbox for Connectivity

    Visit IBM developerWorks to try the IBM SOA Sandbox for connectivity. The SOA Sandbox for connectivity provides a trial environment with the tooling and components to help you explore how to effectively connect your infrastructure and integrate all of the people, processes and information in your company. Use the hosted sandbox to explore SOA techniques that streamline connecting existing IT assets together, as well as learn how to connect them to new business logic.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    CODE EXAMPLES ARTICLES

    - Handling Animations and Bitmaps Using GDI+ f...
    - Download a Web Page using the WebClient
    - Creating a Chart using Data from a Database ...
    - The Basics of Charting with the MS Chart Con...
    - Searching Body Text with textRange: Enter th...
    - Searching Body Text with textRange: Building...
    - Searching Body Text with textRange, part 1: ...
    - First Steps in Programming
    - Programming in C
    - Quick Introduction to ASF,ASX, and Networkin...
    - SatView: Pointer Perfect, Part 2: Constructi...
    - SatView: Pointer Perfect, Part 1
    - Style Case Studies: Construction Unions
    - Creating an Engine for Games for Windows
    - Style Case Studies: Generic Callbacks




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway