|
| Web News |

Phishing scam uses Google Maps to locate victims Account holders with at least two Australian banks have become victims of a phishing scam in which malicious code reveals the physical location of affected IP addresses using Google Maps. Bank account holders in...
German broadcaster buys price-comparison website ProSiebenSat.1, one of Germany's four main broadcast groups, has bought an advertising-funded price-comparison website, www.billiger.de, for an undisclosed sum as it expands into internet businesses.
E*Trade tests global trading E*Trade Financial, an online bank and brokerage, has launched a pilot platform that offers U.S. customers electronic access to foreign stocks and currencies in international markets. The platform, which will be widely available in the second quarter, allows E*Trade's...
DNS root server attack launched from Germany The distributed denial-of-service attack against the DNS root servers earlier this month was launched from a host server in Germany that controlled millions of zombie machines in South Korea, according to a report in...
Yahoo Offers Mobile Display Ads In 19 Countries Yahoo is now offering mobile display advertising though its Yahoo Mobile Web service in 19 countries, extending the graphic ad platform for phones that it launched in the United States late last year. Yahoo is serving...
Construction Company Streamlines Project... For Leonhard Weiss, a leading construction company based in Germany, completing projects on time and to budget is vital. To achieve this, Leonhard Weiss relies on good communications and effective collaboration...
|
|
02.22.07
ASP.NET - A Simpler AJAX Implementation
By Mads Kristensen
A week ago I wrote about the native client callback feature of ASP.NET 2.0 and why it isn't always the smart choice.
That post got me some good feedback that inspired me to build a custom callback implementation so you wouldn't have to use the native one. I could just use other AJAX libraries such as ASP.NET AJAX or Ajax.NET, but that's not fun.
When I started thinking about this little project I imagined it to be complex, but actually it turned out to be extremely simple with very little code. It is less than 100 lines of code including the JavaScript and code comments. Remember, that this is not an all-in-one AJAX framework, but a simple and fast way to do client callbacks.
Good things
•
Uses GET instead of POST for performance reasons
•
Doesn't send the ViewState to eliminate the overhead
•
Simple implementation
Limitations
Because it doesn't send the ViewState you are not able to check the state of the controls on the page. You can use the Session and Cache and any other store, just not the ViewState. You cannot implement it on custom server controls, because it only works on pages.
Implementation
The solution consists of two things: a base class for the page and a small JavaScript file.
Step 1 - change inheritage
In the page you want to do client callbacks, just inherit from CallbackPage instead of System.Web.UI.Page and override the IncommingCallback(string argument, string context) method. Here is an example of such a page's code-behind file.
Try a Better Way Today. Try WebEx MeetMeNow - Click
Here |
|
Step 2 - Insert JavaScript
Next, add the JavaScript file to the header of the HTML document or copy its content into your own script file.
The JavaScript file contains one method that creates the callbacks and it is called CreateCallback. I'll show you how to use it below. That's the entire implementation.
Example of use
Let's imaging that we want a text box where the visitors write their name. When they click a button, it verifies the entered name server-side and sends the result to a JavaScript function.
Continue reading this article.
About the Author: Mads Kristensen currently works as a Senior Developer at Traceworks located
in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in
2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and
web services in his daily work as well. A true .NET developer with great passion for the simple solution.
http://www.madskristensen.dk/
|