Search This Blog

Friday, January 27, 2012

Cross domain useing of silverlight plugins on html page

In this article I am going to show you how to bind or consume  a silver light plugin or xap file hosted on some other domain on your html or aspx page  
using the following code you can easly load a xap file on your html or php or aspx page like a flash file 
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" id="silverlight-plugin"
            style="height:300px; width: 300px;">
            <param name="source" value=""/> url of the server where xap file is hosted
            <param name="windowless" value="true"/>
<param name="onError"
             value="onSilverlightError" />
      <param name="background"
             value="Black" />
      <param name="minRuntimeVersion"
             value="4.0.50524.0" />
      <param name="autoUpgrade"
             value="True" />
<param name="enablehtmlaccess" value="true" />

          <param name="initParams" value="MyParameter=123,Value=123abc," />

                You need to install Microsoft Silverlight to view this content. <a href=""
                    style="text-decoration: none;">Get Silverlight!<br />
<img src="" alt="Get Microsoft Silverlight"
                        style="border-style: none;" /></a></p>
        <iframe style="visibility: hidden; height: 0; width: 0; border-width: 0;"></iframe>
Issue facing while consuming a xap file

if you are using the above code and you are not able to bind the component only an area is highlighted of the above mentioned height and width
in my case  style="height:300px; width: 300px;" . 
you should check the following thing
1) the url of the xap file is ok and when you paste in browser , it should start download like pdf or any other doc file.
if its not like that check for the url.
2) if the above line is ok check your firewall for that particular IP. it should not be block on your network.
3)You must have silverlight installed on your browser
if all the case are fine and still you are facing the same problem then problem is only with your hosting server. any googling is not going to help you out any more
B) if your component are loaded successfully and you are not able to use any jquey or javascript on your silver light component check the following line is added or not if not place the belo line inside your <object> tag
<param name="enablehtmlaccess" value="true" />
In my next article i will show how to code and deploy a xap file and solve the above issue of cross domain hosting
since then
Happy programming.

1 comment :