I've used an object tag to load my Silverlight control because I want to be able to input html into a Sharepoint page using the Rich Text Editor. It looks like this:
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" id="SilverlightObject"
width="850" height="600">
<param name="source" value="ClientBin/LabsSurvey.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="minRuntimeVersion" value="3.0.40624.0" />
<param name="autoUpgrade" value="true" />
<img src="ClientBin/InstallSilverlightLabsBanner.jpg" alt="Please Install Silverlight" />
<br />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/>
</a>
</object>
I've use the Javascript bridge in other Silverlight apps, and it works great for two-way communication between the web page and the Silverlight control.
BUT – it seems that in order for this to work, I have to instanciate my Silverlight control using the .NET Silverlight control.
I can not get a javascript call to a method within my Silverlight control to work when I've used the object tag. I set it up exactly the same way as in my other apps where it does work – the only difference is that the control was not embedded the same way in the html.
Does anyone have any tips for me?
Best Answer
It's also key to include the windowless parameter in your object definition in addition to the information called out in the answer from Kelsey. Without windowless=true, the call to Content will always return undefined....
Sample object definition:
VB.Net class to register scriptable object:
_ Partial Public Class MainPage Inherits UserControl
Public Sub SayHi() MessageBox.Show("HI!!!!!") End Sub
End Class
And the javascript function, registerSilverlight
}