[Sample Code] TravelNews now available for ASP.NET AJAX 1.0 Beta 2

Last night I blogged about my TravelNews demo site and I've already had requests for a version that works with the latest ASP.NET AJAX bits. So here you go. That download link now gives you the option of downloading the Atlas July CTP version or the ASP.NET AJAX 1.0 Beta 2 version.

What did I have to change?

  • Copied the web.config from a newly created ASP.NET AJAX site
  • ScriptManager and ServiceReference prefixes both change from Atlas to asp
  • Moved the ScriptManager out of the <head> section and into the <form>
  • Removed the XML script which did two things
    • It hooked up my GetTravelInfo function to the Application.Load event
    • It (rather gratuitously) created a component from my "info" <div> just so I could use the $ shorthand syntax to reference it in JavaScript
  • So, to resolve that change I had to
    • Hook the Application.Load event up manually in JavaScript (Sys.Application.add_load(GetTravelInfo))
    • As I added this to me TravelNews.js script file I had to add the reference to this on the page to after the ScriptManager
    • Use document.getElementById("info") instead of $("info) to reference the "info" <div>
  • This was the one that caught me out for a while - add a [ScriptService] attribute to my web service

That was it. Bob's your uncle and job's a good 'un.

There is a good document available on the ajax.asp.net site describing how to take Atlas applications and update them to ASP.NET AJAX.