Tuesday, February 17, 2009

My First Silverlight Application

After reading about Silverlight Overview and Silverlight for ASP.NET developers, I hope you got the basic idea about Silverlight and You must be bored enough without doing any implementation and also excited to create something in Silverlight to get an idea how it works, how to create our first "Hello World!!!" application using Silverlight, how it is different from ASP.NET application.



Basic Requirements to create Silverlight Application
  1. Install Visual Studio 2008

  2. Install Visual Studio 2008 SP1 or .NET Framework 3.5 SP1

  3. Install Silverlight Tools for Visual Studio 2008 SP1

Now you are ready to create your first Silverlight Application.

Following are the steps you need to follow.

Step 1: Open your Visual Studio 2008 IDE

Step 2: Open File Menu - > New - > Project



Step 3: Select your choice of Language and select Silvelight in Project Type and select Silverlight Application in Templates. Select Location of your Silverlight Application and in Name box type "HelloWorld" and click OK.


Step 4: It will ask you for options about hosting silverlight application. We need a webpage (it can be html, asp, aspx, php, or any supported webpage) to host our silverlight application. Please select "Add a new ASP.NET Web project to the solution to host Silverlight." Select "ASP.NET Web Application Project" in Project Type drop down and Type Name "HelloWorld.Web". (These all are defaults.) Click on OK.


Step 5: Visual Studio will do some processing and open following screen. If Page.xaml is not open by default, open Solution Explorer and open Page.xaml.

Step 6: We will add some text in our page. Inside the "Grid" tag type following.

<TextBlock>
Hello, My first step to the world of Silverlight.
</TextBlock>

Step 7: Press F5 to run your application. You can see the output in your default browser.

Visual Studio manage lot of things for us, that we need to know.

1. Your startup project is the Web Application, which hosts your Silverlight Application.

2. It creates a space at client side to run the silverlight application. You will find ClientBin folder in your web application.

3. You can find .xap file, which is nothing but the compressed file that contains all dlls required to run your silverlight application. (Rename your .xap file to .zip and uncompress this file to view the contents. You will find all components of your silverlight application.)

4. Open your "HelloWorldTestPage.aspx" and "HelloWorldTestPage.html" and see how we can host silverlight control in aspx page and html page.

Congaratulations!!!! You started working with Silverlight. In next article we will see more about Silverlight Architecture and after that we will continue with different examples with Silverlight.

Monday, February 16, 2009

Silverlight for ASP.NET Developers

After reading my first blog, I am pretty sure you will definitely want to know more about Silverlight. Here are few more things you may interest in, if you are looking forward to work with Microsoft Silverlight. If you are thinking to work with Silverlight then the probability is very high that you worked with ASP.NET. Here we have something that will be helpful to all ASP.NET developers, who are still in confusion.

Are you an ASP.net developer?????

You can create good-looking and robust application using ASP.net that may scale to enormous numbers of users considering good design time. But creating something more than just a functional user interface, something that really excites and drives the user, something that leaps out and wows the user, has always been an uphill struggle because a standard web application cannot take advantage of the client’s processing power to support a rich and powerful UI. You can combine HTML and JavaScript to achieve great results, but it will cost you good time and you also need to manage large scripts written to achieve these results. To run these scripts cross-browser and cross-platform is even more difficult. Finally all these results in thousands of lines of JavaScript code, which ends in real nightmare.

How Silverlight can help?????

Silverlight is all about delivering next-generation media experiences and Rich Internet Application (RIA) that has rich, desktop like functionality via the Web. It allows you to easily add video, animation, and improved interactivity to your web sites. Web application acts like a fat client application. We were using AJAX to provide this functionality, but now Silverlight makes it easy and quick regardless of browser you are using and operating system you are using. Silverlight is built upon existing technologies, so any developer having .NET background should feel somewhat familiar and if developer worked with .net framework 3.0 and 3.5 then it will be more familiar. Silverlight also use Visual Studio as default development environment (IDE).

All that is required to run Silverlight in your browser is the Silverlight plug-in, which is completely free download, and takes few seconds to intall it. If user don't have this plugin installed and navigate to a page hosting a Silverlight Application, they will be automatically prompted to install it.

Silverlight2 include:

  • Cross-Platform / Cross Browser Support
  • Streaming media

  • JavaScript Extensions

  • Digital Rights Management(DRM) of media files.

  • WPF-Like Graphics (Subset of WPF controls)

  • .NET Framework (Based on Subset of .NET framework)

  • Rich Control Library

  • Dynamic Language Runtime (DLR: Support for dynamic languages like Ruby and Python)

  • Language Integrated Query (LINQ: use native syntax and strongly typed objects to program data access)

  • Asynchronous update (No need to refresh page)

  • Communication (Via XML Web Services, WCF Services, REST, and ADO.NET Data Services)

  • HTML/Managed Code Bridge (bridge between HTML and Managed Code)

  • Mobile Support (Support for Windows mobie and Nokia S60 devices)

What you should still do in ASP.NET?????

Silverlight provides lots of new functionality with RIA, but this doesnt meant that now onwards ASP.NET will only be used as a container for Silverlight Application. There are some things that you should still need to do in ASP.NET.

  • Security Consciousness (Silverlight runs on client machine, which is not a safe place for sensitive data)

  • Architectural Awareness (data access code and similar code in ASP.NET and provide access points for Silverlight.)

  • Environmental Concerns (Silverlight plugin may not be allowed in all environments, it may against someone's policy)

  • Ease of Development (few things like validation controls for data entry are easy to include in ASP.NET)

Development Environment Overview

It is very easy to setup an environment to develop Silverlight application.

  • Visual Studio 2008

  • Silverlight Tools for Visual Studio 2008

  • Microsoft Expression Blend (Optional but very handy tool to design Silverlight Applications)

Friday, February 13, 2009

Silverlight - What, Why, and How???

Silverlight Overview

Microsoft Silverlight is a cross-browser, cross-platform implementation of the .NET Framework for building and delivering the next generation of media experiences and rich interactive applications (RIA) for the Web. Silverlight unifies the capabilities of the server, the Web, and the desktop, of managed code and dynamic languages, of declarative and traditional programming, and the power of Windows Presentation Foundation (WPF).

What is Silverlight?

Silverlight enables you to create a state-of-the-art application that has the following features:

  • It is a cross-browser, cross-platform technology. It runs in all popular Web browsers, including Microsoft Internet Explorer, Mozilla Firefox, and Apple Safari, and on Microsoft Windows and Apple Mac OS X.

  • It provides a consistent experience no matter where it runs.

  • It is supported by a very small download that installs in seconds.

  • It streams video and audio. It scales video quality to everything from mobile devices to desktop browsers to 720p HDTV video modes.

  • It includes compelling graphics that users can manipulate—drag, turn, and zoom—directly in the browser.

  • It reads data and updates the display, but it doesn't interrupt the user by refreshing the whole page.


Why Silverlight?


  • Deliver compelling cross-platform experiences

    • Highly sophisticated RIAs

    • HD video and advanced streaming techniques

    • Unparalleled interactivity with high-res content

  • Increase team productivity and collaboration

    • Rapid development with a full set of controls

    • Flexible programming model that supports .NET, Python, Ruby, JavaScript

    • Easy to add richness to AJAX apps

    • Role-specific productivity tools to enhance designer-developer collaboration


Running Silverlight-Based Applications

  • Silverlight-based applications run in the browser. Silverlight makes sure that you can
    run your applications in all modern browsers, without having to create browser-specific code.

  • To run a Silverlight-based application, users require a small plug-in in their browser. The plug-in is free. If users do not already have the plug-in, they are automatically prompted to install it. The download and installation take seconds and require no interaction from the user except permission to install.


Operating
system


Internet
Explorer 7


Internet Explorer 6

Firefox 1.5, 2.x, and 3.x

Safari 2.x and 3.x


Windows Vista


Yes

-

Yes

-


Windows XP SP2 / SP3

Yes

Yes

Yes

-

Windows 2000

-

Yes

-

-

Windows Server 2003 (excluding IA-64)

Yes

Yes

Yes

-


Mac OS 10.4.8+ (PowerPC)

-

-

-

-


Mac OS 10.4.8+ (Intel-based)

-

-

Yes

Yes



Top 10 Silverlight Real World Implementations


Hard Rock Cafe Memorabilia - http://memorabilia.hardrock.com/
NBC Beijing Olympics - http://www.nbcolympics.com/video/techpreview.html
Microsoft Videos - http://www.microsoft.com/video/en/us/default.aspx
WWE / ECW X-Stream - http://www.wwe.com/shows/ecw/silverlight/ecw
Microsoft Health Common User Interface - http://www.mscui.net/PatientJourneyDemonstrator/
Torque TV - http://www.torque.tv/
Microsoft Popfly - http://www.popfly.com
Wish43 - http://silverlight.interknowlogy.com/wish43/
RobotChamps - http://www.robochamps.com/
Microsoft Live@edu - http://my.liveatedu.com/


3rd Party Support

More detail here. List the suites of silverlight tools + summary of their contents

e.g.



Vendor

Component


Supported?


Status


Release
Date


Microsoft


Standard UI Controls e.g. textbox, label, grid, treeview


Y


Production



Microsoft


Chart Controls


Y


Production



Microsoft


Map Controls


Y


Production




Microsoft


Gauges


Y


Production




Infragistics


Standard UI Controls e.g. textbox, label, grid, treeview

Y

Preview

Q2 of 2009


Infragistics


Chart Controls


Y


Preview


Q2 of 2009


Infragistics


Map Controls


Y


Preview


Q2 of 2009


Infragistics


Gauges


Y


Preview


Q2 of 2009



Addition to Microsoft Silverlight WPF controls there are other 3rd party control providers also announced their support to the Silverlight. E.g. we can use “Silverlight Line of Business controls” from Inragistics to achieve following.

  • Push the envelope of performance with a Silverlight grid that has data and UI virtualization, and a Silverlight tree that has lazy loading integrated into its core.

  • Create powerful designs for your next generation Web application through Silverlight's native styling and templating, supported by each control.

  • Build the best business applications imaginable.

Development Resources

Documentation for Silverlight is very easily available on internet and MSDN is the best resource for any kind of help. Apart from MSDN, books and forums are easily available for Silverlight. We can find examples and Silverlight samples on the internet. Some links to Silverlight web resources

http://msdn.microsoft.com/en-us/library/bb404700(VS.95).aspx

http://silverlight.net/quickstarts/

http://www.microsoft.com/Web/content.aspx?id=IT-Mentors-SilverlightFundamentals-5-CustomControls

http://silverlight.net/GetStarted/

http://cid-71b364b59919d1e8.skydrive.live.com/self.aspx/Public/blog%20files/

http://www.apurvalawale.com/silverlight.aspx



There are many more Silverlight resources available on the internet. Link to list of Silverlight books

http://www.silverlightbooks.net/


Why WCF (Windows Communication Foundation)?

  • Complete streamlined Technology

  • Provide access to ASMX, PHP, Java, TCP, named pipe, and JSON-based services by add a single XML element for each type of connection you want to support.

  • Works the same for both .NET and Silverlight

  • Purpose of using WCF: your address, your binding, your contract and your implementation, and UI are complete separate

  • By using WCF we can use our existing code in service implementation and expose as WCF service.

Technical Challenges using Silverlight

  • Complete new Asynchronous programming model: ASP.NET is the server-side technology while Silverlight is for client-side. This is officially the end of request/response architecture.

  • Clients as consumers of your server-side data: Silverlight requires you to think in terms of clients as consumers of your server-side data, which also contain code that executes to handle the end result of the data it receives. You have two applications to write now. Rather than processing the user’s view on a server, you’re much better served asking a server through a service call for some data, and then rendering that data through code executed right on the
    client’s desktop.

  • Silverlight has its own mscorlib.dll: This is the reason we can’t use .net class libraries with
    Silverlight because it is designed to be
    lightweight, quick to download, and not prone to the security nightmare. We can’t use many .net classes with Silverlight. Silverlight is a sub-set of .NET, but it is not .NET. In fact you can think of Silverlight as a really large copy-paste job with some very large missing pieces. (We need to keep in mind that this will make lot of
    our existing code useless and we need to re-write these pieces, and this is the only reason we have to use WCF as a middle layer to access .net classes.)

  • Your entities are not entities: Silverlight applications of any complexity will ultimately have to work with copies of your objects (or perhaps copies of your DTOs which are copies of your entities), because they come in the form of a proxy to the real thing, facilitated through contracts, such as WCF serialization. Since a Silverlight application must only consist of
    other Silverlight assemblies, it makes sense that you’d have to effectively duplicate all of your classes on the client, have no server classes at all, or represent those classes somehow with a
    proxy.

What costs, if any, would be incurred by a switch to Silverlight?

Considering the fact that except all above challenges we may find new challenges at the time of development and fewer resources compare to ASP.net 2.0. We have to accept that it will take fairly good amount of time at initial stage of development to solve technical issues that will occur to accept new technology. Also we have to re-write existing web functionalities to provide support for Silverlight, and we have to redefine the web architecture to use WCF and Silverlight. As we already have all software and tools available from Microsoft and Infragistics We will not have any extra cost for tools and technologies.