开发者

Identifying Silverlight at server side

开发者 https://www.devze.com 2022-12-13 21:50 出处:网络
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 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?

开发者_StackOverflow

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!


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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消