I have a page with a silverlight app on it. Embedded in my page is an authentication key which the silverlight app will need to do all web service requests. So onload the silverlight app needs to get the key and do an initial connect to a WCF service. The problem is that its very unpredictable whether the page or the silverlight will load first, so I cant use the pages onload= event because sometimes the silverlight is null, and I cant use silverlights initialize method because sometimes the js function is still undefined - which I presume means its loading the page from cache, which loads the SL, and only then parsing the JS.
Thanks.
You can get Silverlight interop to invoke a JS method and get its return value using the following:
// Returning a String
string stringValue = (string)HtmlPage.Window.Invoke("myJSMethod");
where myJSMethod
returns the embedded key. But if you're embedding the key anyway, why not just put in into the <object><param>
s?
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="myKey" value="myKeyValue"/>
...
</object>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With