在我的JavaScript創建我<OBJECT>
標籤傳遞參數去Silverlight應用程序
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);
這是我的Silverlight應用程序,我在我的Web應用程序調用的參考。問題是我的<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
總是計數= 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>
什麼樣的價值是'data'在這種情況下?你可以仔細檢查頁面中最終呈現的HTML代碼嗎? –
我嘗試過傳遞一個靜態值,如'value ='chave_id = 1''但沒有成功 –
'data'將返回數據庫中insert的id。 –