Category Archives: AJAX - Page 4

The best ways to incorporate the benefits of AJAX without making your site blind to search engines

The guys at softwaredeveloper.com posted quite good article showing how not to use cloaking, div layering:

AJAX gives developers the ability to build dynamic web applications without the need for constant server side script parsing, enabling you to provide users with simulated “load on demand” sites. That means shorter page loading times, a sharp decrease in bandwidth consumption and more accessible information in general.

Unfortunately, developers are often so focused on creating a dynamic web page, that they forget that most website traffic today comes through search engines, search engines which have a hard time crawling and indexing the JavaScript in standard AJAX sites. In plain english, that means that in Google’s eyes, many of your AJAX site’s pages are invisible when it comes to search engine ranking. Compounding the problem is the fact that standard AJAX implementations use only a single page or URL for the majority of actions, meaning that not only are your site’s pages indexed poorly, but that your site also has fewer pages in Google’s index.

To help you as you incorporate the benefits of AJAX without making your site blind to search engines, we’ve assembled a guide of the best (and the worst) solutions for creating an AJAX page that maintains the ability to be indexed by Google. Here is our how to guide on getting Google and AJAX to play nice.

The Wrong Approach

The Little Things

AJAX allows you to incorporate a lot of innovative site design characteristics. Some designers take the AJAX craze too far, however, by incorporating AJAX to a degree that it hurts their site’s usability and accessibility. Here are a few of the most common problems.

* Making it too simple. Designing sites where AJAX controls everything and serves content on a single page can be a search engine ranking disaster, as your website will have only one URL for everything. Instead, be sure to offer unique sub-links and URLs for popular site features.
* Disabling browser controls. Since AJAX does not communicate with your browser’s history, simple actions like hitting your browsers back and forward buttons are rendered useless. Although you may not traverse your website via browser buttons, many users do. Make sure you’re not overdoing AJAX so much that users get lost in your website.
* Not using Google’s Webmaster Tools. These tools are a simply and reliable way to keep track of the pages of your website Google is indexing.

Cloaking

If Google cannot read the JavaScript components of your site, an obvious solution is to just provide an alternative readable version for Google, right? Wrong. Engaging in cloaking is a bad approach for making your AJAX website search engine friendly, because it is likely to get your site blacklisted and removed from Google’s index entirely. Cloaking occurs when a developer creates two distinct versions of the same website, with the second version (usually plain HTML/text) only visible to search engine spiders. Spammers have long used the technique to hide popular phrases and links in the invisible content in order to artifically rank better in search engines, and Google has responded by banning these sites. To make sure Google doesn’t confuse your site for one that’s up to no good, make sure your crawlable site is derived from the same site your visitors are seeing.

DHTML Layering

If you’ve read other articles on making AJAX sites search engine friendly, you’ve probable read that you should create DHTML layers of your content. While that solution might be effective for producing an attractive interface, however, it is absolutely the wrong approach to achieving better search engine rankings, as DHTML (typically) requires JavaScript to function properly. So how could it be possible to fix a JavaScript compatibility problem by throwing more JavaScript on it? It’s not. Still not convinced? Try readying Google’s Webmaster Guidelines and check out this case study.

Abandoning AJAX

Perhaps the easiest (read laziest) solution is to just abandon AJAX altogether in favor of server side scripting languages such as PHP or Perl. While these languages are powerful enough to perform virtually every operation, they lack the same interactive feel that AJAX websites produce. Now we’re not saying you should completely avoid using server side scripting languages; however, for front-end pages requiring a lot of simple interaction with the consumer we’re all for AJAX.

The Right Approach

Getting Started

Here are a few general tips you should follow when developing a search engine friendly AJAX website.

* Design your site with degradable AJAX, that way users with JavaScript disabled can view a working version of your website along with JavaScript enabled visitors.
* After you’ve established a non-AJAX working version of your website, go back and include an alternative AJAX enhancements where you desire.
* When designing, make sure to check your website with JavaScript disabled as well as through the eyes of a text only browser such as Lynx or SEO-Browser.
* Perform a browser check to make sure the user has JavaScript enabled, that way you’re only serving AJAX pages to users that can view them.

It is extremely important to follow this methodology for widely used site features such as navigation bars. After all, if the user is unable to traverse the pages of your website, what is the point of offering content?

Hijax

Hijax is potentially the most reliable and resourceful solution for developing an AJAX website that properly renders for every user (JavaScript enabled or not) and is also Google spider friendly. To employ the Hijax model, you’ll need to start off by building a standard website equipped with basic links and server side submission techniques. From there, use JavaScript to intercept those links, submissions and other user interactions and pass the information via XMLHttpRequest. Through this process, your website is able to selectively update individual parts of the page in “real time” without the need for constant reloading. Confused yet? We were too at first, but after following this easy guide everything suddenly became clearer.

Excerpt from Progressive Enhancement with Ajax:

JavaScript pseudo-protocol – AWFUL!
contextual help

Pointless link – BAD!
contextual help

Using the DOM – BETTER.
contextual help

No inline JavaScript – BEST!
contextual help

Noscript

You can generate a degree of search engine recognition for your AJAX webpages by using the noscript element. The noscript element “allows authors to provide alternate content when a script is not executed.” For more information on implementing the noscript technique, check out this informative article.

Sitemap

Now that you have incorporated some of the pro search engine AJAX design recommendations, you can get the ball rolling for your website by submitting a Sitemap index file to Google. Sitemaps allow a “webmaster to inform search engines about URLs on a website that are available for crawling.” Keep in mind simply submitting a sitemap isn’t enough, you’ll need to engange in a combination of the previously mentioned techniques for the best results. For more information check out Sitemaps Wikipedia file.

At this point you should have enough information and resources to build an AJAX enhanced, search engine friendly website. From basic design principles such as incorporating degradable AJAX into your site to utilizing Noscript techniques, you can create an AJAX website that is not only accessible to both JavaScript enabled and disabled users, but also one that will be well-indexed by search engines.
read original

New ASP.NET AJAX Control Toolkit Release

Scott is writting about the new ASP.NET Ajax Control Toolkit. Here is his post:

Yesterday the ASP.NET AJAX Control Toolkit team released an updated version. You can download it from the http://ajax.asp.net web-site, and run samples built with it on the online samples page here.

The ASP.NET AJAX Control Toolkit is a free download and contains more than 40 additional AJAX controls and components that work on top of the core ASP.NET AJAX 1.0 release. In addition to having Microsoft developers contribute, the project also has more than 15 non-Microsoft contributors adding great features and controls.

You can download either a binary version of the ASP.NET AJAX Control Toolkit to use (just add to your toolbox and you are good to go), or you can download the source for the project itself and tweak/extend it if you want (all source is released under a permissive license allowing you to make your own modifications to it).

New ToolkitScriptCombiner Support

One of the biggest improvements with this toolkit release is support for a new “ToolkitScriptCombiner” control. This control allows you to replace the default control behavior, and supports the ability to dynamically merge multiple client-side Javascript scripts into a single file that is downloaded to the client at runtime. Better yet, only the Javascript needed by the specific controls on the page are included within the combined download, to make it as small as possible.

The big benefit with this feature is that is can significantly reduce the number of Javascript files the browser needs to download, as well as reduce the overall download size of the scripts. This can provide some really nice performance and load-time wins on pages. Best of all – you don’t need to change any code or refactor any script yourself to take advantage of this.

Other ASP.NET AJAX Control Toolkit Improvements

This week’s release contains a number of other new improvements, including:

  • More than 125 bug fixes
  • Extended client side event support – new client side event handler extensibility points are available with common toolkit server controls
  • ASP.NET Validation Controls now work with the Toolkit Controls
  • Accessibility fixes: Slider and AutoComplete have support for high contrast and other controls have JAWS accessibility support built-in when doing AJAX callbacks.
  • Animation support: More toolkit controls now have generic animation support built-in
  • Nice design mode improvements for the controls, including: 1) designer support for the TabContainer. You can now select/add/remove tabs within the tabcontainer directly from the designer, and you can directly edit both the content and the title, 2) page methods can now automatically be generated for those extender controls that call web-services, 3) nice icon support within the toolbox.

You can learn more about all of the improvements in blog posts from Shawn, David, Kirti and Garbin.

ASP.NET AJAX Control Toolkit Videos

Joe Stagner has been cranking away at recording “How Do I?” videos for the AJAX Control Toolkit, and now has 39 free ASP.NET AJAX “How Do I?” videos hosted on the www.asp.net site.

step2 New ASP.NET AJAX Control Toolkit Release

Click here to watch them for free and learn how to-do common tasks with ASP.NET AJAX and the ASP.NET AJAX Control Toolkit. The most recent videos are now available to download in a variety of video and audio formats, including: WMV, Zune, iPod, PSP, MPEG-4, and 3GP.

ASP.NET AJAX Books

As I mentioned in my links post from last week, the first books specifically targeting the final ASP.NET AJAX 1.0 release were recently published. Below are links to two of them that are shipping today:

step4 New ASP.NET AJAX Control Toolkit Release step3 New ASP.NET AJAX Control Toolkit Release

Both books include a chapter on using the controls within the ASP.NET AJAX Control Toolkit.


read original

The JavaScript Dilemma

The last post from Rick Strahl’s blog! Its a great piece of reading. Check it out also here(at the bottom I have a link to his original post):

rick The JavaScript Dilemma

In the last year or so the Ajax lifestyle has become common practice for Web development even in the developer mainstream after a few years where the technology was primarily treated as bleeding edge technology. Today however, Ajax is drifting more and more into the mainstream of Web development and you’d be hard-pressed to find a Web development tool that doesn’t support it in some highly abstracted way.

Ajax is all about JavaScript and HTML DOM scripting and I thought in this column I’ll review some of the approaches that are available to satisfy the requirements to build richer client applications and offer some thoughts on issues that I am struggling with as I compare the choices available for my own development and solutions that I work on with customers.

It’s pretty clear that the days of hand coding most of the JavaScript to deal with client side logic are over. These days the complexity of what’s happening on the client and the UI is quickly getting as complex if not more so than what’s happening on the server. And while in the past we might have written a couple of lines of JavaScript here or there to validate forms, these days the requirements are much more involved. It’s almost a foregone conclusion that the client side now also requires some sort of framework which is often completely decoupled from the server side.

JavaScript Frameworks

At the moment client side frameworks are all the rage. There are basic JavaScript libraries that help with common tasks automating the DOM. The most popular along these lines is Prototype which provides basic JavaScript language enhancements as well as basic browser independent DOM manipulation functionality. Many other libraries build ontop of Prototype to build additional libraries the most common of which these days are user interface widget libraries. Dojo and Yahoo’s Widgets are examples of Widget frameworks. Similar are effects libraries like Scriptalicious, Moo.fx

ASP.NET Ajax

The first stop for most ASP.NET developers likely is the MS Ajax toolset along with its various support libraries. MS Ajax provides both a server centric and client centric toolset. The server side functionality is primarily driven through the UpdatePanel control that allows wrapping server side controls and containers into an updateable panel container that allows for partial page updates. This component is the basis of MS Ajax’s server functionality and provides a core set of features that can be taken advantage of by other controls. The MS Ajax Control Toolkit can also be used in combination with the MS Ajax library to provide many other controls that provide server centric implementations with client side. The Control Toolkit takes uses a common pattern to create client side control implementation and also expose the control or behavior via a server side control which allows getting the base behavior exposed in a way familiar to ASP.NET developers with a minimum or no client side scripting.

MS Ajax also includes a large client side JavaScript framework that provides core language features and basic HTML DOM accessibility through a common JavaScript API. The key feature of the client side framework is that it provides a .NET like type system and a common implementation pattern for classes and components. So you will typically use a set of guidelines based on namespace, interfaces and classes to implement your classes. You’ll use property get/set syntax for property declaration and invocation when creating your own classes and the framework more or less forces you into a specific way of doing things which is both a good thing and a bad thing depending on whether you agree with the design decisions Microsoft made. But the rigid structure of the framework also means that using it requires a certain discipline and in some ways is much more verbose than other JavaScript frameworks.

The client side framework in version 1.0 can be thought of as core framework services rather than as a complete Ajax framework. This includes the type and language facilities, extensions to some of the base JavaScript objects and the base Html DOM element. Of course there’s also support for remote communication via XmlHttp both on a low and high level as well as JSON serialization facilities and the ability to use ASMX and WCF Web Services.

To me MS Ajax is completely mixed bag. On the one hand I think Microsoft did a great job of providing a deep framework that is modeled closely to the .NET framework’s design which makes it somewhat familiar to .NET developers. But on the other hand the framework is bulky and it feels very rigid and formal in its implementation and usage.

But there’s no doubt that there is some allure in MS Ajax because it provides a single framework for client and server. The above mentioned rigidity of the framework can also be advantageous to control developers as it clearly forces common patterns for implementing components that work and expose functionality consistently. There are also many advanced features baked into the client framework like localization, testing and instrumentation at every level and not just at an afterthought.

Pure JavaScript Frameworks

Microsoft started from scratch when they built MS Ajax but there are a number of very popular JavaScript libraries available most of which are easier to use and more light weight to boot.

If you are a developer who’s familiar with JavaScript and not afraid to code on the client side, a raw JavaScript library might offer you much more flexibility and options to create cool interfaces because there are a large number of libraries available. The most difficult portion of a JavaScript/Ajax framework is the browser interoperability and functionality extension of the base JavaScript objects and basic DOM objects and all of the libraries I mention here address this scenario. These libraries do away with the inconsistency of dealing with various browsers which is easily the biggest time waster when dealing with client side scripting. Take that away and you might find that JavaScript coding is not a big deal after all.

The most popular among the JavaScript frameworks is Prototype which is a highly usable and relatively small library that provides JavaScript type extensions and a large number of DOM abstraction and enhancement functions. Prototype is small and concise and is easy to pick up by anyone reasonably familiar with JavaScript which accounts for its popularity. It’s definitely going to be less familiar to ASP.NET developers as it’s clearly a JavaScript centric framework. Prototype has pretty much become the yardstick by which other libraries are compared. Prototype is also the basis of many other higher level frameworks and many smaller add-on libraries exist that provide specialty functionality on top of Prototype.

There are other frameworks that follow a similar base approach. A couple of others that I’ve used on several occasions are jQuery which is very light weight and provides mostly AJAX/ JSON functionality, plus basic browser abstraction. MooTools is a full featured library that focuses heavily on effects (like drag and drop, animation etc) . I’ve found MooTools to be very enjoyable to work with and it feels like the cleanest and easiest to use implementation of the JavaScript frameworks I’ve played with. It also uses a very Prototype like base implementation although it doesn’t rely on Prototype itself so it will be immediately familiar to users of Prototype. Mootools also has a cool feature on their site that lets you customize the MooTools JavaScript library by feature so you get only the features you want include in your set (or sets).

Other libraries yet aim to extend the popular Prototype library. script.aculo.us for example, provides an effects library that runs on top of Prototype as does Moo.Fx, which is a tiny effects library that can work with Prototype or as part of MooTools.

All of the the libraries I’ve described so far (including the MS Ajax client library) are really core framework libraries. They provide language, object and DOM extensions, but they don’t provide much in the way of new user interface functionality. There are a number of libraries available that address this space with Widget frameworks. A couple of prominent entries in this space are Dojo, the Yahoo UI Library and even OpenLazlo (works either with Flash or DHTML) which provide a host of client controls. These frameworks are big and are often complex to use, but they provide really rich client side functionality that allows building interfaces that mimic desktop applications to some degree.

The good news with any of these tools is that they will work without any sort of server implementation so they’re easy to drop into any application – simply reference the JS libraries and off you go.

Unlike MS Ajax these libraries are purely client side – they know nothing about ASP.NET and the server side. But that’s part of the benefit of these frameworks as they are completely server agnostic. Communication between client and server is provided using XmlHttp and JSON serialization, deserialization, but if you plan on using it in combination with ASP.NET you probably will want to at least implement a custom JSON service interface that you can use to pass typed data between client and server. There are several open source .NET JSON libraries available (JSON.net, here and also my own wwHoverPanel) that make short work of this task. wwHoverPanel for example implements a self-contained HttpHandler implementation that lets you call JSON methods and return results from them.

Other ASP.NET based libraries like Anthem.NET, Ajax.NET and several others also provide server side JSON functionality. These libraries are also options for ASP.NET developers, but they tend to be server centric, and my focus here is on client side scripting so I won’t go into more detail here.

Build your Own

When I started out with Ajax about 3 years ago, roughly about the same time Microsoft announced MS Ajax (Atlas at the time), I also got excited about Ajax functionality and thought that it wouldn’t be too difficult my own library with some basic functionality. Before long the library grew into a small client framework with a very focused feature set that did exactly what I needed in my applications and life was good. However, I also quickly found out that building your own is not as trivial as it sounds at first once you go down the path of building more sophisticated functionality. My library ended up adding things like drag and drop functionality, modal dialogs, pop up windows and various basic effects. At the time my JavaScript skills were pretty creaky and it took a bit of time and refactoring of the JavaScript code to get up to speed and actually understand more about JavaScript’s language peculiarities and browser DOM quirks. This is an ongoing effort that continues to this day.

Today as I’m looking back I’m really glad I went through this experience as it taught me tons about JavaScript that I probably would have never figured out and now I feel at least reasonably proficient with JavaScript not to cringe at the thought of having to write client script. But I also realized that writing sophisticated client side JavaScript DOM code is damn hard especially if it has to work across many browsers and I really started to appreciate the efforts that have gone into libraries like Prototype or MS Ajax’s client library.

I still see a lot of value in building a custom library, however. If I had to do it over (and I may) I would almost certainly use one of the more prominent base frameworks as my base library and build on top of it. Using Prototype or MooTools would cut my framework code in half and let me focus on the specialty features I want in my framework.

The design I chose ended up creating matching client and server controls for most components built in such a way that the client control interfaces largely matched the server controls. The key features were to provide easy and flexible remote callback functionality to the server, a small windowing library that makes it easy to present pop up window content, along with a host of basic client side behaviors all in a small package. And finally combining all of this into an easy to use ASP.NET based interface.

Building your own is probably an edge case, but I’m often surprised how many people like me have gone down this path mostly because in the early days there weren’t as many choices available as there are today. The advantage with this approach is that you can build a truly customized framework that matches your toolset. It can also be beneficial to do this as a tool developer so you can provide additional functionality that is self contained. For example, even today with MS Ajax you can’t easily have client side code call back into a control without major hassles but with a custom interface it’s as easy as adding a method to a control and calling it from the client side. These are the kind of things you may never see in an official framework but are indispensible when you’re dealing control development for example.

Script#

So far I’ve looked at client side JavaScript coding which is often regarded as a hassle. But there are a also a few alternatives available that let you code in a different language and output JavaScript from it. One such tool is the Google Web Toolkit which lets you write Java code to generate JavaScript code. Being a .NET developer using Java doesn’t sound so enticing, but luckily there’s a .NET project available that provides similar functionality by using C#.

Nikhil Kothari is one of the Program Managers on the ASP.NET team and he keeps cranking out some highly valuable and useful tools. One of the most exciting tools he’s created some time ago and recently updated is Script#. Script# at its core is a C# compiler that rather than spitting out MSIL compiled assembly spits out JavaScript source files. There are two pieces to this magic – the actual compiler/parser that does the translation and a set of libraries that provide the supported set of features that you can use with the C# code you write. The thing to understand is that you don’t get access to the full CLR and .NET libraries, but rather to a specific subset that is available to Script# and capable of being mapped into JavaScript code.

The benefits of this approach are that you get full support for a rich editing environment in Visual Studio, strong type support and Intellisense for the supported features.

There are a number of ways that you can create Script# generated JavaScript – one is inline inside of pages via a Scriptlet control that can contain C# code that gets converted on the fly and a more traditional library type approach that creates a separate .js files.

One of the cool things that Nikhil has done is provided a mapping assembly that provides a good chunk of the MS Ajax client library so you can generate code for MS Ajax compatible controls and behaviors. But even without the MS Ajax support, Script#’s core JavaScript support libraries provide many of MS Ajax’s type system like namespaces and class registeration etc.

Script# is an interesting concept and Nikhil himself has used it for building a number of controls and helpers he’s published recently which is a validation of this concept for real work in a lot of ways.

Unfortunately this project currently has not been given any official support from Microsoft, so currently it’s impressively maintained by Nikhil himself. The toolset includes pretty good integration into Visual Studio .NET with project and item templates and integrated editor support for most things in the way you’d expect from C# source editing. But some of these integration features are a little rough around the edges which is to be expected for an early release (0.3.0).

I’ve played around with Script# off and on and it provides some really interesting possibilities, but somehow I can’t shake the feeling that this is somehow limiting my options for coding general purpose JavaScript. Script# also subscribes to the MS Ajax way although it can work without MS Ajax. If I were to build MS Ajax controls I think I would start seriously looking into this tool to provide some of the core plumbing. Script# will manage things like automatic property creation (MS Ajax style), class and namespace registration, handling and providing Intellisense for the core MS Ajax infrastructure which provides great discoverability and a great reduction in the amount of plumbing code you have to type to create the tedious MS Ajax client code.

There’s a lot of potential for this sort of tool as a lot of people feel a lot more comfortable in the C# vs. JavaScript. But without official support from Microsoft it’s unlikely that this tool will gain wide acceptance although there are certainly some people who will find it useful for their work.

SilverLight 1.1 and .NET on the Client

Microsoft recently announced SilverLight 1.1 and one of the features of the 1.1 version when it releases later this year or early next year will be the capability to run .NET code on the client. I don’t want to dwell on the rich user interface features of Silverlight here since this has been beaten to death recently, but rather focus on the .NET programmability and the ability of the .NET code to reach out and manipulate the HTML DOM from within the Silverlight .NET runtime. This gives yet another option for managing client side code using a .NET language rather than JavaScript. This means that you can use Silverlight in combination with .NET to write fully standard compliant HTML.

The way this works is that the .NET runtime hosted in Silverlight provides a programmable reference to the HTML DOM that Silverlight is hosted in. This may be IE or FireFox or Safari on the Mac or Windows. Silverlight provides interface to the the browser’s DOM and allows automation of it.

In concept this is a great idea, but before you get too excited remember that the current DOM support is very limited and deals primarily with accessing HtmlElement at the raw DOM level. There’s no browser abstraction or any support for specific HTML constructs. However, it’s quite possible to extend this basic functionality using .NET code to provide a much richer abstraction and browser independent access to the DOM. This would require somebody to build a browser abstraction layer first, but once done imagine the benefits that this would bring: You could build a browser abstraction layer that’s driven through the .NET coding model providing all the benefits of compilation and discovery and of course Intellisense.

We’re not there yet, but the possibilities of this technology have tremendous promise not just to address the flashy scenario we’ve seen so much of with Silverlight but also using Silverlight as a behind-the-scenes scripting engine for the HTML document.

Too many Choices?

As you’ve seen there are quite a few options available these days to build client side code. It’s no longer just about the remote AJAX functionality but also about building rich and snazzy client side interfaces.

There are many ways to skin this cat. The Ajax framework market is hugely fragmented and this is a problem especially since many of the Ajax frameworks and tools are so drastically different that moving between them is nearly impossible.

Even if you look only at the ASP.NET space, you’ll find that the MS Ajax release late last year has not found the universal adoption that’s typical for anything major coming out of Microsoft. While MS Ajax almost certainly has quickly become the most prominent ASP.NET Ajax framework by default, many early adopters of Ajax technologies are finding that MS Ajax is not a must-switch solution and continue on with their existing tools. That may change as time goes on and MS Ajax matures and adds more useful functionality that makes it more compelling as a client side tool.

Where does that leave us? I feel right now just about all of the Ajax tools out there are immature and often buggy. That doesn’t mean they don’t work, but they are not necessarily easy to use or maintain. The best that we can do as developers is to try and pick a toolset and stick to it if possible. But even that is often difficult if you work with multiple clients that have different preferences for the toolset used. Over the last year I’ve worked with at least 5 different Ajax frameworks on various projects and switching between these frameworks and building interfaces that run on top of them is not optimal to say the least. But it’s become a fact of life.

For my own internal work I’ve also landed myself in a dilemma. Do I stick with my custom built solution, or do I bite the bullet and make the switch to MS Ajax just because in the ASP.NET space at least it’s as close as it gets to a standard implementation? Even though I’m less than thrilled with that toolset? Or do I stick with what I got, possibly refactor and use a base library like Prototype? That’ll be most likely the path I take, but for now I’m sticking with the original framework I built. There are a lot of choices to make, benefits and tradeoffs to weigh.

Ajax and client side development is here to stay, but we are bound to see some consolidation and stabilization over the next few years. These are turbulent times.

Welcome to Web Development in 2007.

read original

Silverlight and JSON

Another artcile by Michael Schwarz, check it out here:

Silverlight 1.1 comes with an built-in JSON serializer which can serialize common data types like string, numbers and arrays. It includes a object serializer, too, I think it is nearly the same as in ASP.NET AJAX or Ajax.NET Professional.

I modified my IsolatedStorage demo and added a new method called GetFiles(string pattern) which will return an array of string containing the file names in the storage. Because I already did the managed JavaScript (DLR) demo in on of my earlier posts I’m now using C# (I love Silverlight, I can choose my favorite language all the time).

namespace IsolatedStorage{   [Scriptable]   public class Storage   {       [Scriptable]       public string GetFiles(string pattern)       {           using (IsolatedStorageFile isf =                  IsolatedStorageFile.GetUserStoreForApplication())           {               JavaScriptSerializer jss = new JavaScriptSerializer();               return jss.Serialize(isf.GetFileNames("*.*"));           }       }

       [Scriptable]       public bool WriteText(string filename, string s)       {           try           {               using (IsolatedStorageFile isf =                      IsolatedStorageFile.GetUserStoreForApplication())               {                   using (IsolatedStorageFileStream fsm =                          new IsolatedStorageFileStream(filename,                                           FileMode.OpenOrCreate, isf))                   {                       using (StreamWriter sw = new StreamWriter(fsm))                       {                           sw.Write(s);                       }                   }               }           }           catch (Exception)           {               return false;           }

           return true;       }

       [Scriptable]       public string ReadText(string filename)       {           try           {               using (IsolatedStorageFile isf =                      IsolatedStorageFile.GetUserStoreForApplication())               {                   using (IsolatedStorageFileStream fsm = new                          IsolatedStorageFileStream(filename,                                       FileMode.Open, isf))                   {                       using (StreamReader sr = new StreamReader(fsm))                       {                           return sr.ReadToEnd();                       }                   }               }           }           catch (Exception)           {               return null;           }       }   }}

Because Silverlight (or the Scriptable methods) don’t support more complex data types until now (I hope this will change in future releases) we have to return a JSON string that will be parsed on the client-side JavaScript later.

The JavaScriptSerializer is included in the namespace System.Windows.Browser.Serialization. You have to create a new instance of the JavaScriptSerializer class and call the Serialize method which you pass the .NET object you want to serialize. In our example it is a string array we get as result of the IsolatedStorageFile.GetFiles method.

On the client-side JavaScript code I use the eval statement, hm, is not the best way to parse JSON, but the easiest. Of course you can use the ASP.NET AJAX parser or the JavaScript parser at json.org:

var control = document.getElementById("SilverlightControl");var storage = control.Content.Storage;

// save any data to the storagealert(storage.WriteText("test2.txt", "Hello World!"));

// read data from the storagealert(storage.ReadText("test2.txt"));

// get all filenames in storagevar files;eval("files = " + storage.GetFiles("*.*")); // eval parse JSONalert("Files: " + files.join(","));

You can download this example here. For those of you don’t have Visual Studio Orcas installed I have included the binary files, too. So, simple double click on the TestPage.html. If you run the example you will see three message boxes: the first will display true if writing was sucessful, the second one will display the content of the file specified in the argument. The last message box will display all filenames in the storage.

read original

May 31st Links: ASP.NET, ASP.NET AJAX, Visual Studio and .NET

Once again Scott is delivering essential links:

Below is this week’s list of useful .NET links for my weekly link-listing series.

This morning I also updated my ASP.NET 2.0 Tips, Tricks and Gotchas Page to also include some more recent content posts I’ve done on my own blog this past spring. This page list ~60 past blog posts I’ve done, organized by category (VS, UI, Data, Security, Deployment, Performance, etc).

ASP.NET

  • SubSonic Documentation and Project Site: SubSonic is a great, free, open source project for ASP.NET that provides a highly productive OR/M implementation that can dramatically improve productivity when building data driven sites. Earlier today Rob Conery and the SubSonic team launched their new documentation and product home site – complete with videos, walkthroughs and samples. Definitely worth checking out.
  • Rolling Your Own Website Administration Tool (Part 1) and Part2: These two recent 4GuysFromRolla articles cover how to build an online user and role management system on top of the ASP.NET Membership and Roles APIs. You can use the approach and code in these articles to integrate an html admin tool to manage users within your site.
  • Official ASP.NET Provider Support from Oracle: Oracle has recently released a beta providing updated support for connecting to Oracle databases using .NET. Included within this release are pre-built ASP.NET providers for storing ASP.NET Membership, Roles, Profile, Session State, Web Parts, and SiteMap data within Oracle databases. This download also adds support for ASP.NET database cache invalidation for Oracle databases when using the ASP.NET Output Caching and Cache API features.
  • Asynchronous Page in ASP.NET 2.0: Jeff Prosise has written up a great article for MSDN that covers using ASP.NET’s Asynchronous Page support. Async Pages was a new feature added in ASP.NET 2.0, and can significantly improve performance on your site when you are calling out to a remote web-service or network endpoint by allowing you to yield back your worker thread to ASP.NET while you block on the contents to return from the remote site. Mads Kristensen recently posted a good tip when using this feature – which is to make sure you increase your connection limit to get the maximum benefit from it.

ASP.NET AJAX

  • DotNetNuke 4.5.2 Released: The DotNetNuke team earlier this week released an update of the very popular DotNetNuke portal and collaboration framework. One of the major enhancements with the DotNetNuke 4.5 release is integrated support for ASP.NET AJAX 1.0. Shaun Walker wrote a great blog post that talks more about DotNetNuke’s ASP.NET AJAX support here.

Visual Studio

  • New Free Version of Refactor! for ASP.NET: Developer Express has released a great (free) add-on to Visual Studio 2005 that adds support for 29 refactorings for common ASP.NET scenarios (add validation, extract contentplaceholder, extract style, export to user-control, etc). Definitely worth checking out.

.NET

  • MBUnit 2.4 RTM: Andrew Stopford and team have released version 2.4 of MBUnit – which is a great open source unit testing framework for .NET
  • IronPython Cookbook: This online Wiki contains a ton of good content on how to get started with the IronPython for .NET (Microsoft’s Python implementation)


view original

Google Gears Lets Developers Take Apps Offline

gears sm Google Gears Lets Developers Take Apps OfflineToday, Google is hosting a developer day for 5,000 developers worldwide. The bulk of developers will be gathering at the San Jose convention center for a keynote by Google’s VP of Engineering, Jeff Huber. At the conference Google will be outlinging their developer strategy. But the big announcement will be Google Gearst Google Gears Lets Developers Take Apps Offline, an open source browser plugin that will enable developers to create offline web applications using JavaScript APIs. As a developer, you’ll be able to make an application with the assurance that it will work offline and online across browsers.

The plugin is a 700K download for Firefox 1.5+ and Internet Explorer 6.0+ that installs three developer APIs. One API will handle the creation of data objects to store application information locally, another will be a SQLite relational database for searching the data, and the final part will enable asynchronous JavaScript so applications can sync data in the background without overburdening the browser. More info on the APIs are available at the gearst Google Gears Lets Developers Take Apps Offline website.

googreadgears Google Gears Lets Developers Take Apps OfflineThe first demo of Gears will be for Google Reader, but more Google apps are expected to come. Reader will add a green download button to the user interface. When you click the button, Reader will download the last 2,000 messages to your computer, preparing your computer to work offline or under a spotty internet connection.

Downloading will take place in the background, using the asynchronous JavaScript API. While offline you can read these articles and carry out your usual sharing and tagging. When you get back online, just click the button and Reader will sync your offline activity with their server. Right now the syncing is initiated manually, but it’s easy to see that it will become more seamless as the program develops. Gears could conceivably solve the large data overhead problems of Google’s AJAX applications, pushing updates to your desktop instead of slowing down your browser.

Google is releasing opensource and early to developers to get some preliminary feedback. They are also collaborating with a host of other partners such as Opera, Mozilla, and Adobe, which will to integrate flash and Apollo into their system.

read original
Google Gears Home

Google Web Toolkit – Build AJAX apps in the Java language

code sm Google Web Toolkit   Build AJAX apps in the Java languageGoogle Web Toolkit (GWT) is an open source Java software development framework that makes writing AJAX applications like Google Maps and Gmail easy for developers who don’t speak browser quirks as a second language. Writing dynamic web applications today is a tedious and error-prone process; you spend 90% of your time working around subtle incompatibilities between web browsers and platforms, and JavaScript’s lack of modularity makes sharing, testing, and reusing AJAX components difficult and fragile.

GWT lets you avoid many of these headaches while offering your users the same dynamic, standards-compliant experience. You write your front end in the Java programming language, and the GWT compiler converts your Java classes to browser-compliant JavaScript and HTML.

Today just released GWT 1.4RC with more than 150 bugfixes, in addition to many new features and improvements. JavaScript produced with GWT 1.4 is about 10-20% smaller, but the most interesting that it’s becoming much more faster. Most important change in GWT 1.4 is ImageBundle, which make it easy to collapse dozens of images into a single permanently-cacheable image file, another new feature that will boost GWT performance.

For deployment enhancements, GWT RPC is no longer tied to exclusively to servlets, and we saw already Pibb which uses Python for server-side scripts. Now you can run GWT compiler with -xs option, if you need a cross-site support in your JavaScript loading module, pretty simple but always use it at your own risk. Finally lots of changes in GWT widgets including RichTextArea, SuggestBox, Splitters, and more. GWT 1.4 is going to be hot ! More changes details here. Via GWT blog.

read more
GWT Home

Monthly Ajaxian Roundup for May, 2007

Dion Almaer from Ajaxian.com has written quite good post which showed us what was going on into the Ajax community into the recent month. Here is their post:

We realize that it is an incredible tough job to keep up on what is happening in the Ajax community as it is so broad. We aim to bring you a few posts a day to take some of the burden off of you, but what about broader terms?

We are starting a new monthly roundup that aims to summarize what was important in the preceding month, based on our opinion, but more so on what you, the community, thought of the postings (rating and page views).

We are going to experiment with formats, but by splitting up the content, you can also get a feel for the ajax library landscape over time. Please let us know what you think, and if there is anything else that you would like to see.

Although it is a bank holiday in the US (memorial day), we realize that: a) some geeks don’t care and are working / browsing. b) most of our audience is not in the US. So, for you, we have the first roundup:

High Level / Big News

The big recent news is the emerging talk about the new platform wars of Silverlight, Apollo, JavaFX, and how the Open Web fits into all of this. Episode One may be the browser wars, but maybe Episode Two is the plugin wars?

The press has gone a little nuts on Silverlight and JavaFX. Both are just name changes, and we have known about WPF/E and F3 for quite awhile now. I couldn’t help by have a little fun myself.

On the Ajax front, a very interesting paper was released on a trusted implementation of cross domain access, which will be huge for mashup developers, and we are seeing more and more usage of dtrace to debug apps for Ajax, or Rails.

Browsers and Standards

Alex Russell thinks that the future of HTML is more important than any other worries on the Ajax side, and we agree. Everyone is watching the new W3C group, and although the group has taken on HTML 5 from the WHATWG, we wait to here how it will get tweaked. The group has been a little quiet.

Ajax Librarys

The core Ajax libraries are flourishing. They are getting more and more lean, mean, and solid. It becomes harder and harder to choose between then, and we are getting abstractions on top, such as Ext JS that are providing even more functionality.

Dojo

Dojo has announced a new 0.9. If you are watching this closely you will see that this is a big deal. This isn’t a slightly different Dojo. This is a revolutionary Dojo. The biggest complaint on the library has been the feeling that it is too bloated (it is incredible comprehensive). Do widgets need to be abstract enough to grok SVG and HTML (when the community is only using the HTML ones)? Does the remoting support need to bundle every funky transport layer? No. And, the Dojo team has realized this and has taken things into their hands and has revamped the framework as a lean, mean, beast that checks in at roughly the same size as Prototype. There is now ONE dojo.js instead of having you package, or grab, one of many.

Dojo is being reborn as we speak, and the results are exciting to see.

Prototype
Prototype chucks along as a fantastic, solid, “I just want to add a bit of Ajax guys, not boil the world” Ajax library. Version 1.5.1. was released, and it gets faster and cleaner than ever.

jQuery

jQuery seems to be going from strength to strength. Maybe that is why idiots decided to DOS the project… they don’t like success. The simple plugin architecture is allowing people to add functionality easily to the library without bloating it. Somehow the implementation has resulted in many more plugins in the community than elsewhere.

GWT

I was asked a lot of questions on GWT at JavaOne (no surprised based on the conference). It seems to be picking up steam, and many Java programmers are enjoying the choice.

Mootools

Moo always has a nice little following that produces a lot of content. This month was no exception.

Conclusion

As the month comes to a close, we are looking forward to seeing the new platforms solidify over the summer, as frameworks go from alpha to beta to live.
The Ajax Experience Call for Papers Closed, and we are once again amazed at the community who made our choices incredibly tough.

Ben and I sat down and went through them all with the first pass acting as a “lets mark the must-haves first and then go back” walk through. Once we were done with that we already had chosen more content than we could fit in.

We can’t wait to see you on July 25-27 in San Francisco.

As always, if you see anything that you feel the community would enjoy seeing, please email us and let us know so we can cover it on the site.

read original