Silverlight - RIAs don't have to be that hard to create

by Ishai Hachlili 12. April 2008 15:03

I remember a time when rumors about Microsoft buying Macromedia were circulating, it was obvious why they would want to buy Macromedia, Flash was THE rich interactive web application standard, and it was beginning to dominate online video as well.

As someone who suffered a lot with the Flash studio (being a programmer and not a designer or animator) I was happy with the idea of getting that side of Flash fixed. If there's one thing the folks at MS know how to do well, it's their dev tools and the support for this tools.
Flash was felt limited to me, both in the way you had to develop for it and in the way you communicate with the hosting page or the server.
You had to do very complicated solutions for very simple tasks.

When Adobe ended up buying Macromedia, I was disappointed, another designer's company meant the environment and tools won't get much better.
I was surprised MS didn't try to get flash until they revealed their own solution for RIA, online video and animation. I guess they also didn't like a lot of things about flash and decided to simply create their own plugin and it was called WPF/E, at least until the PR guys woke up and renamed it Silverlight.

I haven't worked with flash for a couple of years, and I'm sure a lot of the things that were bothering me were solved, maybe, but recently someone tried to convince me that Silverlight was terrible and had no chance of besting Flash.

So this is what I see as advantages for silverlight:

  • Use JavaScript to write you client side code. the upside here is big, every web developer (should) know JavaScript, there's no need to learn another programming language or work with another set of tools. this also means the same developers can do the standard javascript programming, AJAX programming and RIA programming but it also means integrating silverlight into your AJAX apps should be easy.
  • Silverlight 2.0 adds support for .Net on the client side. This means a lot of things including better performance, support for other languages (C#, Ruby, python, VB.Net, etc...). This also means all the .Net developers can now work on RIAs, so it's not only those who know JavaScript.
  • XAML. Having an XML based format means you can very easily generate it on the run, on the server side or on the client side. If you need to customize a page based on database results or if you want to allow users to create XAML snippets and add them to a page, it's all just xml and should be pretty easy to do. This also means other tools for creating XAML should be available from 3rd parties (like the export plug ins from illustrator and flash)
  • Video using wmv. I never liked FLV, the quality is bad and I just didn't see any reason for it to exist (remember, when it came out we had quicktime, wmv, and real media videos)
  • Microsoft is behind it. This puts the flash has 98.5% install base claims to bed, at least for me. If it was some new, small, no-name company, it would've been hard, even with a better product, but I'm pretty sure MS will make sure it's on every computer and it looks like they learned from their mistakes, instead of just making it part of an update you must install or shipping it with windows, they're getting big content providers to use it. After the summer Olympics, when NBC will be using Silverlight to broadcast thousands of hours on the internet, I'm sure a lot more people will have the plug-in installed (and no, silverlight won't cause a crash, the media servers might, but that has nothing to do with silverlight).
  • Silverlight is available for IE, FireFox, and Safari on the Mac (and at least on FireFox it works well for me). Another lesson learned by MS. No linux support from MS, but I think there's a plug-in in the works by someone else (ehh, who cares, it's not like a lot of the RIA users will be using linux anyway, they don't like pretty things...)

As with previous Microsoft efforts, when they show up late, they learn from others' mistakes and make a better product.
This happened with .Net, which basically took JAVA and did it the right way, or C# which eliminated a lot of problems VB, C++, JAVA and JavaScript had, and now with Silverlight.

I've only played around with SilverLight for a few days, but it's such a better experience compared to working with Flash and I have to say that as a team leader I like the fact that my team members, who all work with .Net and JavaScript, will be able to learn silverlight programming very quickly.


Ajax Data Controls (Repeater, Data List and Grid View)

by Ishai Hachlili 18. February 2008 13:14

ADC is a set of data controls that try to mimic the Asp.Net controls using Asp.Net AJAX Extensions.

I'm looking at the GridView in particular, although I never really liked the Asp.Net control, the AJAX version might work well for my search pages.
For the current project I'm working on I won't be using the server side wrapper, just the client side code.

The grid view control supports paging, sorting, column dragging, links, checkboxes and in-place editing.

I'm going to try it out, see if it takes the places of my upgraded WebFXColumnList...

check it out at Ajax Data Controls - Home


AJAX | Asp.Net | Javascript

You should never forget your (browser) history

by Ishai Hachlili 18. February 2008 10:44

One of the most annoying things in AJAX based applications is clicking the back button and going back to a previous url and not the previous state of the application.
Users are trained at clicking the back button if they went to the wrong place and need to get back to the last place they were at. Even when I know I'm using an AJAX app, I would click it by mistake.

What happens when uses click the back button in your AJAX application?
I've worked on a lot of back office web applications and when an application uses AJAX with only one real page (in the same way gmail does), clicking back will usually take you to the login screen, and that's not where you wanted to go.

Adding History to an AJAX application
Fortunately, this problem has been solved. You can manipulate the browser history and control what happens when a user clicks the back button.
Even better, Microsoft’s AJAX library adds easy support for setting history points and going back to them, so you don't have to write the code yourself.

Let’s take a look at the AJAX search sample, where we had next and previous buttons to navigate the search results.

Whenever a results page is shown I want to add a history point.

Here's the code I'll use to set a history point in JavaScript:

Sys.Application.addHistoryPoint({showPage:pager.CurrentPageIndex},'MyTakeOnNet - Search Results - Page ' + pager.CurrentPageIndex);

Sys.Application.addHistoryPoint takes two parameters, the first one can be any object you want, you will use this object to decide what to do when the user goes back to this history point. the second parameter is the title of the page.

If you add this line of code to the pager's ShowPage method, you'll see the history button's drop down will have a new entry for each page.

Handling the history navigation
Every time a user navigates through the browsers history by clicking the back button or selecting a history point from the back buttons drop down, the MS AJAX library raises an event.
To subscribe to this event, add the following line of code when the page loads.


and add the onNavigate function to handle the event
function onNavigate (sender, e) {    //get state and make change to application    var state=e.get_state();    if (typeof(state.showPage) != 'undefined') {        if (pager.CurrentPageIndex != state.showPage)            pager.ShowPage(state.showPage);    }}

The get_state() call will return the object you saved as the first parameter of the history point, you can then use this parameter to show the page.

Pretty simple, right?
It does get more complicated if you remember that a user might execute several searches and page through them, so the search parameters should be saved as well with the history point.
You have to make sure you cover the entire state of you AJAX enabled page to make sure you can re-create that state when the user clicks the back button, but at least you don't have to write the code to deal with the browser's history


AJAX | Asp.Net | Javascript

About Me

Ishai Hachlili is a web and mobile application developer.

Currently working on Play The Hunt and The Next Line

Recent Tweets

Twitter October 23, 05:22
@BenThePCGuy a standard where that doesn't matter is better. One more reason to get the #Lumia920, wireless charging, no need for microUSB

Twitter October 23, 05:21
@ManMadeMoon where they dance around the issues and don't really talk about them

Twitter October 23, 05:20
@BenThePCGuy are you a @wpdev ?

Twitter October 23, 04:17
@JonahLupton But if it's black it's usually better

Twitter October 23, 02:58
@jongalloway next time ask your 5 year old how to spell