在我的javascript中,我创建了<OBJECT>
标记
var htmlEmbedSilverlight = "<div id='silverlightControlHost'> "
+ "<object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='550px' height='250px'> "
+ "<param name='source' value='../../ClientBin/FotoEmprestimoChave.xap'/> "
+ "<param name='onError' value='onSilverlightError' /> "
+ "<param name='background' value='white' /> "
+ "<param name='minRuntimeVersion' value='4.0.60310.0' /> "
+ "<param name='autoUpgrade' value='true' /> "
+ "<param name='initparams' values='chave_id=" + data + "' /> "
+ "<a href='http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.60310.0' style='text-decoration:none'> "
+ "<img src='http://go.microsoft.com/fwlink/?LinkId=161376' alt='Get Microsoft Silverlight' style='border-style:none'/> "
+ "</a> "
+ "</object><iframe id='_sl_historyFrame' style='visibility:hidden;height:0px;width:0px;border:0px'></iframe></div>";
$("#tiraFotoSilverlight").html(htmlEmbedSilverlight);
这是我在我的Web应用程序中调用的Silverlight应用程序的引用。问题是我的<param name='initparams' values='chave_id=" + data + "' /> "
,因为在我的Silverlight App.xaml
中,我有以下代码
private void Application_Startup(object sender, StartupEventArgs e)
{
if (e.InitParams != null)
{
foreach (var item in e.InitParams)
{
this.Resources.Add(item.Key, item.Value);
}
}
this.RootVisual = new MainPage();
}
InitParams
总是有Count = 0,我不知道为什么。有人能帮我吗 ?我只是尝试将值传递给我的Silverlight应用程序,而不是PostBack
。
渲染
<object width="550px" height="250px" type="application/x-silverlight-2" data="data:application/x-silverlight-2,">
<param value="../../ClientBin/FotoEmprestimoChave.xap" name="source">
<param value="onSilverlightError" name="onError">
<param value="white" name="background">
<param value="4.0.60310.0" name="minRuntimeVersion">
<param value="true" name="autoUpgrade">
<param values="chave_id=1" name="initparams">
<a style="text-decoration:none" href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.60310.0">
</object>
答案 0 :(得分:0)
您为param
的{{1}}标记使用了错误的键/值对。您使用initparams
时应该<param values=
(注意单数“值”与复数“值”)
将您的JavaScript行更改为:
<param value=