tags:

views:

43

answers:

3

What I have?

I have a web part on which I am displaying a hierarchical diagram picking the information from a List. The diagram is drawn using Silverlight and HTML.

What I want to do?

I want to show Silverlight diagram if Silverlight is installed on the client machine otherwise I want to show HTML diagram.

What problem am I facing?

I want to check if Silverlight is installed or not on the server side and render the appropriate diagram. Basically, I don't want to use JavaScript to identify it and do a unnecessary post back for loading the diagram.

Is it possible to achieve this on the server side?

Thanks for your time!

A: 

I am not sure, but I don't think it is possible. There is nothing in the browser string which identifies silverlight support. Anyway, the additional fetch of the silverlight will not typically be very expensive if you are using HTTP 1.1.

Amigable Clark Kant
Anyway, this feels a bit like the blind leading the blind. Will someone please chip in with their knowledge?
Amigable Clark Kant
A: 

Strictly speaking, it isn't possible. You have no access to the client side other than through the HTTP cycle and consequently, you need a client side mechanism of returning this information, i.e. something like JavaScript.

What you could do though, is position the diagram with CSS and position the Silverlight over the top (again using CSS) if it's present. To be honest though, this would have as much overhead as the roundtrip would as you'd always be loading the data twice. If you require Silverlight to display the diagram, then simply make it a requirement that the user must install Silverlight to view it - after all, you'd expect them to load Flash if they wanted to view a Flash image.

Pete OHanlon
+1  A: 

You could give this a try:

<asp:Silverlight runat="server" ID="SilverlightControl"
    Source="~/Control.xap" Windowless="true">
    <PluginNotInstalledTemplate>
        <!-- here go your HTML fallback content -->
    </PluginNotInstalledTemplate>
</asp:Silverlight>

Of course, this can be translated to a <OBJECT> element, if you're not using ASP.NET

Rubens Farias
And needs to be translated to object tag anyway since this ASP.NET control has be dropped since SL3
AnthonyWJones
I didn't knew that, as I'm working on 2.0; ty for this information, Anthony!
Rubens Farias