Blog

Know latest trends and updates on Technology!

Slider

How to Use Silverlight in ASP.NET


The very purpose of Microsoft Silverlight is to allow .NET developers better ammunition for creating rich and interactive web content. Designed ground-up for .NET, it natively supports languages like C# allowing developers to use same language (VB, C#, etc.) and abstractions (LINQ, controls, streams, collections, generic, etc.) to frame client and server side codes. The best part is that one does not need to have the entire .NET Framework installed in order to leverage the technology. The version 4.0 has a cross-platform version included, which means developers can access it on the browser without having anything extra installed on the client. It includes the same CLR engine (GC, Type System, JIT Engine, etc.) that comes with the full .NET Framework, along with a skinned down component of the namespace libraries. The four main components are -one that handles the inputs from devices, the core that manages rendering of images, vector graphics, textual content, animations, etc., the media handler that manages playback of MP3, WMA, and WMV streams, and the one that manages the user interface layout written in XAML.

The technology gels and integrates extremely well with existing web applications, including those on ASP.NET AJAX. In fact they are designed to be complementary in nature and application, while ASP.NET AJAX can additionally be employed for better control of visualizations, e.g. application mapping or video playback with rich presentation. There are typically four or so different scenarios, based on common development approaches, when one has to consider on whether to use either of the technologies or both in tandem.

Pure Silverlight Applications – This circumstance calls for total removal of ASP.NET and generally works best in case of fresh development, as there would hardly be any integration problem. Communication with the server is established through web services (e.g. WCF). Partial or complete hosting or porting of such solutions on different platforms is easy and cumbersome free due to the distinct separation of the server and the client in such applications.

Primarily ASP.NET development with islands of Silverlight components – This works fine when the respective content have little to do with each other in the application itself. A classic example could be a deploying a media player component, developed with the rich client-side technology, in a blog post driven by an ASP.NET engine. This approach is quite common which actually manages to encompass and engage a larger audience – different users with different local technology installs can enjoy different facilities in the blog, without getting completely blacked out due to absence of a specific technology on the local machine.

Pure ASP.NET AJAX application – ASP.NET AJAX is designed to deliver in collaboration with ASP.NET and essentially is an extension of the same. Although AJAX might not match up to Silverlight’s rich and advanced user experiences, it still suffices quite a few scenarios, especially when the skills-sets available in-house are pre-dominantly those of ASP.NET. One of the ways to do it would be to blend the client and server codes by using UpdatePanel, Ajax Control toolkit, etc. This is especially easier to implement where JavaScript knowledge is limited. The other one is a pure AJAX approach, wherein HTML and JavaScript is put to use instead of server controls to call web services to communicate with the server. This is a better option when one has to later port AJAX applications onto other technology platforms. The programming model in this case is quite similar to that of Silverlight; especially since one only need to re-work on the client side code, keeping the web services intact.

Combining with ASP.NET – In some occasions one may wish to port an existing ASP.NET application to Silverlight, but might not be interested in re-writing the entire code. A quite challenging approach since it asks for judicious blending of client and server side technologies and the decision to adopt this approach should be substantiated by the following queries and considerations:

Is it essentially a high consumer engaging application and whether it needs a rich interactive user experience, which AJAX might not be able to sufficiently handle?

If it is indeed designed to be a consumer oriented application, could it not be achieved by simply adding Silverlight islands to the existing ASP.NET code base, instead of considering mixing of client and server side content?

The benefits of leveraging existing Silverlight knowledge, components and applications and integrating them with SharePoint 2010 are numerous. Since the codes run on the client, one can utilise threading and asynchronous calls to offer responsive user interfaces and to take advantage of modern multi-core microprocessors in client computers offering great response times. Rich controls, animations, and exhilarating multimedia effects are achieved without overloading the server. It is this Silverlight development capability of isolating processing on the client that creates a self-contained application out of the Portal.

Article Source: EzineArticles