Remote scripting

xiaoxiao2021-03-06  55

http://www.codeproject.com/aspnet/alvaroremotescripting.asp

Download Source and Binaries - 47 KB Download Binaries ONLY - 9 KB

Contents

Introduction Demo Usage Notes

Introduction

How many times have you been on a web page and you selected a value in a drop down box, only to suddenly see the whole page refresh so that it can fetch values ​​for another drop down box? I see it all the time in car web sites. you select the Make of the car and the whole page is reloaded to bring back all the corresponding Models. Then you select the Model and the whole page is reloaded again to bring back all the corresponding Trims. Annoying, is not it?

Some Sites Avoid This Problem by Preloading All The Possible Alternative, But The Are Times WHEN The Amount of Data is Just Too overwhelming for all the possible combination

Remote Scripting offers a better alternative. Instead of the whole page refreshing, a hidden request is made to the server to execute a method which returns back just the data that needs to be changed on the page. The result is a smoother user experience. Indeed , Remote Scripting brings some of the benefits of a traditional fat-client application to a web application. It can be used to refresh individual controls, to validate controls, or even to process a form without having to post the whole page to the server. IT's Cool Stuff!

Over the years, I've seen two popular remote scripting implementations. Back in the days of Visual InterDev 6.0, Microsoft provided client and server-side include files inside its _ScriptLibrary directory. I used it in a few projects and it worked quite well. The only problem I found was that it used a Java applet to handle the communications, so it tended to be sluggish at times. Then I started doing JSP and I found a better alternative called JSRS. Depending on the browser, it created a hidden element on the page that submitted the request to the server which then responded back to it. It was more efficient, but it only allowed the remote calls to be asynchronous.Now with ASP.NET, I've once again needed to use Remote Scripting. I initially wrote a small class library in C # that provided support for both Microsoft's and JSRS's clients. But then I decided to see if I could come up with a better client implementation, and I believe I did. I came up with a hybrid solution based On Both O F THE EXISTING IMEVE LOOKS AND WORKS BETER. THIS ARTICLE PRESENTS My Remote Scripting Client and Server Side Implementation for Asp.net. Enjoy!

Demo

The downloadables include a file called rsDemo.aspx which has a fully working example of this code. It also demonstrates how to populate the drop downs using data from an XML file (rsDemo.xml). The link below goes to the demo page. When You Change The Type, The Amount IS Repopulated Using Remote Scripting.

Demo Page

USAGE

I've strived to make my Remote Scripting implementation as simple and easy to use as possible. There are just a few simple steps to take on the client and server side to get it working. Be sure to look at the rsDemo.aspx file to Get The Complete Picture.Client-Side

Include rs.js in your .aspx page, like this: