Comments
jcl wrote: Hi,thank you for this tutorial I'm interested on the first way to intregate Spring and EJB3. I have tried it in a example project buy it doesn't run. I'm searching since many time a solution,but nothing. I have posted on Spring forum,but no one seems can help me. I appreciate if you can help me.Thank you Antonio
Cloud Expo on Google News

SYS-CON.TV

2009 East
PLATINUM SPONSORS:
IBM
Smarter Business Solutions Through Dynamic Infrastructure
IBM
Smarter Insights: How the CIO Becomes a Hero Again
Microsoft
Windows Azure
GOLD SPONSORS:
Appsense
Why VDI?
CA
Maximizing the Business Value of Virtualization in Enterprise and Cloud Computing Environments
ExactTarget
Messaging in the Cloud - Email, SMS and Voice
Freedom OSS
Stairway to the Cloud
Sun
Sun's Incubation Platform: Helping Startups Serve the Enterprise
POWER PANELS:
Click For 2008 West
Event Webcasts
First Time with AJAX.NET
Exploring this new technology

In a former life, I was a web developer. Back in the late '90s, I vividly remember being told by more than one of my computer science professors that in 10 years, everything would run in a web browser. Even the operating system (it was claimed at the time) would be browser based. On startup, the machine would load the thinnest of all possible operating systems, and everything else - applications, data, you name it - would be stored on the network and accessed via a hyper-dynamic web browser.

At the risk of stating the obvious...this hasn't happened. Part of the reason for this, I'm sure, is that the explosion of bandwidth that seemed so likely at the end of the last century simply hasn't panned out. Coming from the opposite direction, the cost of hardware - both up-front purchase costs and ongoing maintenance - have fallen enough that there is really not much advantage to be gained any longer from "thinning down" entire machines.

In my own case, I have to confess that I've never really been very enthusiastic about the vision anyhow. Network computers seem an awful lot like glorified "dumb terminals" from the late '70s - so I have a hard time envisioning them as a step forward. And, of course, the whole idea of storing all my data and applications out on the network gives me all sorts of concerns about privacy and no longer being able to purchase software outright but, instead, being forced into paying a small fee for every access. Some of us will always prefer to buy than to rent, that is all there is to it.

Of course, much has been made of the "Web 2.0" phenomenon, and in many ways this represents the (to my mind) right-sized approach to the idea of network-enabling content and data. There are two main aspects to Web 2.0. One of these aspects is the leveraging of the Internet to make data access and applications more inherently communal and multi-user interactive. Examples of this would be social networking sites like Facebook or MyPage or even the business-networking site LinkedIn.

What is more relevant to us, however, is the other aspect of Web 2.0 - making web content that is so incredibly interactive and responsive that it seems in many ways like a traditional desktop application. My favorite example of this would be Google Maps. When you pull up a Google map, you are able to flip through multiple views (satellite, traffic, traditional, etc.) and re-center the map on just about any point - hardly ever being aware of the numerous network requests that are feeding your requests as you go along.

If you contrast this with the way that a similar browser-based application might have been constructed just five years ago, you might recall that the experience would almost certainly have been much worse. In those days, any request to change the data displayed would have resulted in the all-too-familiar "wait, blank, new page" cycle. Even though the "blip" might only have lasted a second on sufficiently fast machines and connections, the disconnect in thought process was sufficient that web applications developed this way would never really stand any chance of displacing traditional applications for most uses. Solving this is where AJAX.NET enters the picture.

AJAX.NET - What Is It?
AJAX stands for "Asynchronous JavaScript and XML" and was, of course, in no way, shape or form a Microsoft invention. It could be debated, really, as to whether any one person or group could ever truly claim credit for its invention. I personally remember having created a web page that used DHTML, JavaScript, and the Internet Explorer HTTP request object way back in 2000 to allow users to update a server-based database from a form without having the form do a full-submission and resulting "wait, blank, new page" routine.

What makes AJAX fundamentally different from previous uses of JavaScript and XML is that the usage pattern for these technologies in AJAX is more codified, standardized, and (in many cases) exposed by software component bundles that obviate the need for developers to understand the underlying technologies of JavaScript, XML, or even DHTML. One such technology is Microsoft's fantastic AJAX.NET.

Using AJAX.NET, you can get away from the standard "wait, blank, new page" model of web pages that has existed for over a decade at this point. Instead, components added to an AJAX.NET web page are allowed to create their own connections back to the server to receive updated information and then re-present themselves individually as circumstances require - with no need to reload the page in its entirety.

Quick Example of AJAX.NET
To get your first glimpse of the power of AJAX.NET, we're going to construct a simple timer web page. The idea is that this page will show the current time, updating every second. First, we'll build this using traditional "wait, blank, new page" technology, then we'll update it to use AJAX.NET and see how much better it looks.

Start by loading up Visual Studio .NET 2008. If you choose "File, New Project," and limit the choices to "Web," you will see a number of AJAX.NET-related entries:

  • ASP.NET AJAX Server Control
  • ASP.NET AJAX Server Control Extender

We will discuss both of these shortly, but for right now you can just choose to create a standard ASP.NET Web Application.

When the HTML source code for the page appears, change to the Design view. Drag a label from the toolbox to the design surface, and then a button. Double-click the button on the design surface to go into code view. You should be focused on the Button1_Click event. Inside this method, enter the following code:

Label1.Text = "" + DateTime.Now;

Now, if you run the application, you will find that every time you hit the button, the entire page reloads and the current time is shown. This would seem to be the "Hello World" counter-example for AJAX - you're getting the data you want, but in order to get it, you have to take explicit action, and it results not just in updating the desired location - meaning, the label - but, instead reloading the entire page.

Now, let's look at an AJAX.NET-enabled version of the same page. Return to Design Mode for the page and scroll the toolbox down to the "AJAX Extensions" part of the UI. When you expand this, you will see several options:

  • ScriptManager
  • ScriptManagerProxy
  • Timer
  • UpdatePanel
  • UpdateProgress

Each of these components serves an important purpose, but arguably the most important of them all is the ScriptManager. You aren't going to be able to take two steps into AJAX.NET without adding a ScriptManager to your page. This component serves as the "brain" for all the AJAX stuff you are going to do on a given page, so drag-and-drop that component onto your page right now, please.

The next thing we need is an UpdatePanel. In short, things that are in UpdatePanels can be updated asynchronously (the "A" in AJAX) and those that are not, cannot. So, drag an UpdatePanel onto your page's design. And then, drag your existing label into the UpdatePanel - because this is what we are going to want to update asynchronously.

The final component we will add to the page - specifically, to the UpdatePanel - is the Timer control. Drag and drop that now. The Timer is going to allow us to request that the content of this UpdatePanel update themselves every X number of milliseconds, so we don't have to force our user to keep hitting the button over and over again.

Like the Windows and Threading Timer controls, this control has properties for Enabled and Interval. If Enabled is set to True, the code behind the timer will fire every X millisecond. You specify the value for X using the Interval property. Since Enabled should default to True, take a moment now - using the Properties window in Visual Studio, to set the Interval to 1000. This will make the code behind our timer run once-per-second, since there are 1000 milliseconds in a second. When you have done this, your solution should look like the Figure 1.

This leads us directly to our next, and final, bit of software development - which is to add code behind the timer. Double-click the Timer1 control, when you get the code-view to pop-up, copy the code from your button to the inside of the new Timer1_Tick method, as shown below.

protected void Timer1_Tick(object sender, EventArgs e)
{
Label1.Text = "" + DateTime.Now;
}

After adding this code, re-run the application, you will now see that the time on the page updates every second without your having to click the button. If you set a break-point in the Timer1_Tick method, you will see that this is also happening by way of a call back to the server. The important difference is that it is not the entire page that is being re-flowed by way of new HTML being sent down to the client. Instead, specific XML-based content is being sent down to the HTTP request running on a background thread and the DHTML model of the page itself is being access to update the relevant content, which in this case means the label showing the time.

Besides the AJAX controls that ship out-of-the-box with Visual Studio 2008, there are a wide variety of similar controls available on the Internet, and these have additional features and capacities. After this brief introduction to the AJAX.NET technology, it is my hope you will be encouraged to explore further and figure out ways to use this exciting new technology in your own applications.

About Andrew Montgomery
Andrew Montgomery is a freelance technical writer based in the Chicago area.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Thanks for sharing Andrew. I recently got started with AJAX and .NET and discovered that Web.config settings are important!


Your Feedback
Carol Skelly wrote: Thanks for sharing Andrew. I recently got started with AJAX and .NET and discovered that Web.config settings are important!
Latest Cloud Developer Stories
Large enterprises and government agencies are drowning in data. IT teams deploy a myriad of data warehouse-centric solutions – BI, predictive analytics, data and content mining, portals and dashboards – to harness and deliver data for intelligent decision-making. Yet, large enter...
As a preface to the series of articles I will be writing on the Value Proposition and Business Cases for Cloud Computing, I wanted to discuss the layers below and within the cloud. It is important to understand what each of the layers is composed of, what the intended function of...
Rackspace Hosting announced a new service to assist its e-commerce customers this holiday season. The Rackspace Holiday Shopping Mall, a promotional area hosted on NoMoreServers.com will offer discounts and coupons to encourage holiday shopping and highlight the benefits of using...
I've been at this 35 years and I've seen sea changes come and go. If you step back for a moment and look from a broad perspective, we've lived through the mainframeclient/server world and the Internet world. And now, the next sea change is cloud computing. The reality is that vis...
Cloud computing is a game changer. The cloud is disrupting traditional software and hardware business models by disrupting how IT service gets delivered. Entrepreneurial opportunities abound as this classic disruptive technology begins to proliferate, so it is no surprise that SY...
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 Cloud Computing News

PrismTech™, a leader in high-performance software integration and infrastructure so...