YOUR FEEDBACK
Adobe Flex 2 - Answering Tough Questions About Enterprise Development
A Correct Person wrote: Denis Roebrt commented on the 21 Aug 2006 "Tough Que...

SYS-CON.TV
TOP MICROSOFT .NET LINKS


Volta is to AJAX What Tums is to My Stomach
In a typical AJAX application, your goal is often to have the user click something for JavaScript to go out and do its thing

Digg This!

Kevin Hoffman's Blog

This is a deliberately oversimplified example. I typically hate oversimplified examples, but I think most people reading this blog will be able to extrapolate the useful bits from this sample out into practical uses. Also, Volta is still a CTP and subject to radical change in the future, so I'm not so worried about conforming to best practices yet, since there are none :)

In a typical AJAX application, your goal is often to have the user click something. In response, JavaScript goes out and (through the magic of XML HTTP Requests) obtains data and potentially modifies data on a server as well. Using the returned data, the JavaScript can then directly manipulate the HTML DOM to make it appear to the end user as though things just dynamically happened in a manner very similar to a traditional desktop application.

While there are lots of libraries that enhance and abstract on top of that functionality, that is essentially the core of what AJAX is and why it is so popular. The problem is that everybody's got their own flavor of AJAX library, and some of them require you to write a truckload of JavaScript. Most of the tools for dealing with Ajax, even the most advanced ones, still require the developers to think in terms of multiple paradigms, multiple tiers, and potentially even multiple languages and/or development environments - all just to get a little change to happen to a page without doing a visible refresh. Not worth it, IMHO. I've got better things to be doing, like building application functionality, not twiddling with silly little JavaScript semantics.

So, let's say I have a button that I want to trigger the revealing of a hidden <div>. Sure, it's simple to do in JavaScript, but what I want to show you is how Volta let's you do it all in C#. Here's my contrived HTML:

<body>
    Hello. This is Ajaxy!
   
    <button id="btnClick">Click Me to Reveal
the hidden text!</button>
    <div id="hiddenText" style="visibility:hidden;">
        <b>This is a hidden message!</b>
    </div>
</body>

So, if I started littering this page with some JavaScript, I could get the div to appear. But, what if I wanted the contents of the div to contain a weather report from some remote web service, complete with gradients and images, etc. Now, what if I want to _debug_ that code, and what if I want that code to be strongly typed and unit testable?? Screw JavaScript, it's not going to get the job done.

Here's the code for my Volta page. You can see it grabs references to HTML DOM elements, sets up a purely C# event handler, and manipulates the DOM directly - all in C#, and no mention of browser cap checking, no mention of tier, and no mention of JavaScript. It's all just pure C# from end to end.

public partial class VoltaPage1 : Page
    {
        private Button _clickButton;
        private Div _hiddenTextDiv;
        public VoltaPage1()
        {
            InitializeComponent();
            _clickButton = Document.GetById<Button>
("btnClick");
            _hiddenTextDiv = Document.GetById<Div>
("hiddenText");
            _clickButton.Click += new HtmlEventHandler
(_clickButton_Click);
        }
        void _clickButton_Click()
        {
            _hiddenTextDiv.Style.Visibility =
"visible";
        }
    }

When you run this app, and it launches IE pointing at the Volta web server, you can click the button and see it dynamically reveal the contents of the hidden div. Obviously nobody gives a crap about applications that reveal hidden divs. However, if you want absolute control over your DOM, and you want to leverage your C# experience and be able to designate certain blocks of C# code as running on the server tier without worrying about the busywork of getting around the same-origin policy, then Volta might actually be what you're looking for.

If you can think of some samples that are more practical than this (I wanted to do this as an intro before doing more involved samples), please let me know and I'll see what I can come up with.

tags:          
links: digg this  del.icio.us  technorati  reddit

About Kevin Hoffman
Kevin Hoffman, editor-in-chief of SYS-CON's "iPhone Developer's Journal" is one of the most popular "iPhone" and "Silverlight" bloggers on the Net. Kevin has been programming since he was 10 and has written everything from DOS shareware to n-tier, enterprise Web applications in VB, C++, Delphi, and C. He is coauthor of Professional .NET Framework (Wrox Press) and co-author with Robert Foster of Microsoft SharePoint 2007 Development Unleashed. Kevin authors "The .NET Addict's Blog" at ".Net Developer's Journal" (dotnetaddict.dotnetdevelopersjournal.com).

Robwin wrote: Check this out: http://labs.live.com/volt a/blog/Volta+How+To+Flick r+Widget.aspx This guy also has a site http://www.tanzimsaqib.co m which has loads of posts on volta
read & respond »
iPhone News Desk wrote: In a typical Ajax application, your goal is often to have the user click something. In response, JavaScript goes out and (through the magic of XML HTTP Requests) obtains data and potentially modifies data on a server as well.
read & respond »
MICROSOFT .NET LATEST STORIES
Icahn Moves To Force Microsoft & Yahoo Together
Corporate raider Carl Icahn started his proxy fight for control of Yahoo this morning, beginning with the classic Icahn opening, the letter of reproach to the Yahoo board telling them they have acted 'irrationally and lost the faith of shareholders and Microsoft.'
IBM, Microsoft & Google Eras of Computing
By now it is conventional wisdom to say that there was an IBM Era of computing, then a Microsoft Era, and now we are in the Google Era. In this post, I will explain why Microsoft was not the 'next IBM' and why Google is not the 'next Microsoft' - there are significant qualitative diffe
Book Review: ASP.NET 2.0
ASP.NET developers are bored with traditional books that outline concepts in a lengthy way. These books are good if you like to learn the features in a detailed manner. However, by the time the book is read, a new version will be released. Hence, many learners including myself prefer s
3rd International Virtualization Conference & Expo: Themes & Topics
From Application Virtualization to Xen, a round-up of the virtualization themes & topics being discussed in NYC June 23-24, 2008 by the world-class speaker faculty at the 3rd International Virtualization Conference & Expo being held by SYS-CON Events in The Roosevelt Hotel, in midtown
"RIA" vs "Rich Client Platform": The Term Is Now Up for Debate
'RIA' is slowly fading in terms of its definition. When I first started the RIA Evangelism role in Microsoft, I had this nagging feeling that the term RIA was just all over the place. Depending on which technology you are backing and which stream of alliance you uphold, the truth is th
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE
BREAKING NEWS FROM THE WIRES
Strangeloop Networks Selected for Red Herring 100 North America 2008
Strangeloop Networks (TM) Inc., a leading provider of solutions that accelerate dynamic web