在我的 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 + "' /> "
,因为在我App.xaml
的 Silverlight 中,我有以下代码
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>