PDA

View Full Version : reload <asp:Silverlight> control from Javascript?



winseelan
May 26th, 2009, 05:40 AM
I want to pass the value to initparameters dynamically from Javascript file, so i have written the function like this

<asp:Silverlight ID="sl1" runat="server" Width="770" Height="290"
Source="~/ClientBin/MyProj.xap">
</asp:Silverlight>
function A()
{
CallSLImageComp(1, 1, 0, 'slCheck');
var silverlightApp = document.getElementById("trSL2");
var parent = silverlightApp.parentNode;
parent.removeChild(silverlightApp);
parent.appendChild(silverlightApp);
}
function CallSLImage(data1, data2, data3,ControlName) {
var strParam = "data1=" + data1 + ",data2=" + data2 + ",data3=" + data3;
Sys.UI.Silverlight.Control.createObject(ControlNam e + '_parent', '<object type="application/x-silverlight" id='+ControlName + ' style="height:290;width:770;"> <param name="InitParams" value="' + strParam + '"></param> <a href="http://go2.microsoft.com/fwlink/?LinkID=114576&amp;v=1.0 (http://go2.microsoft.com/fwlink/?LinkID=114576&amp;v=1.0)"> <img src="http://go2.microsoft.com/fwlink/?LinkID=108181 (http://go2.microsoft.com/fwlink/?LinkID=108181)" alt="Get Microsoft Silverlight" style="border-width:0;" /></a></object>');
}
at the first time, its working fine, but if i call the same function again then Silverlight control is not initializing, so that Silverlight control not have any output,
Experts please tell me what is the wrong the code?
http://go2.microsoft.com/fwlink/?LinkID=108181 (http://go2.microsoft.com/fwlink/?LinkID=114576&v=1.0)'); } at the first time, its working fine, but if i call the same function again then Silverlight control is not initializing, so that Silverlight control not have any output, Experts please tell me what is the wrong the code?

kirupa
May 28th, 2009, 01:44 AM
I cannot see your code properly. You should wrap you code in
tags or use the code button in the post editor :)

If you are looking to reload the control via JS, something like the following may work:
[code]document.getElementById("sl1").source="~/ClientBin/MyProj.xap";
:cons:

winseelan
May 28th, 2009, 10:44 AM
I cannot see your code properly. You should wrap you code in
tags or use the code button in the post editor :)

If you are looking to reload the control via JS, something like the following may work:
[code]document.getElementById("sl1").source="~/ClientBin/MyProj.xap";
:cons:

Kirupa thanks for your response.
Is there anyway to pass the Initparameter like above code?