In C#, Asp.net, I’m creating Javascript code through my code-behind :
var silverlightControl = null;
function PluginLoaded(sender, args)
{
silverlightControl = sender.getHost();
silverlightControl.Content.SilverlightScriptableObject.PerformRfidRead(); //**1**
}
function CallSilverlight()
{
silverlightControl.Content.SilverlightScriptableObject.PerformRfidRead(); //**2**
}
var tid = setInterval(RefreshTimer, 2000);
function RefreshTimer()
{
CallSilverlight();
}
It works perfectly on Firefox and Chrome but cannot seems to work on IE 9 ! The PluginLoaded Method is always called properly. But it seems that my “silverlightControl” var lose its value between methods calls…
When calling my Method “PerformRfidRead()” directly after sender.getHost() (cf. 1), everything is normal. When letting the timer do the call every 2 seconds (cf. 2), it seems my var is empty and I receive the following error message :
Content » : null object or undefined
Any idea ?
Thanks for your help.
I finally put my finger on this problem :
Firefox, Chrome and IE9 have different behavior regarding timers !
My RefreshTimer method was called too early and the PluginLoaded method couldn’t be called soon enough to initialize the silverlightControl object !
Therefore, I corrected by doing this :
Hope this can help someone…