【问题标题】:Can not pass parameters to silverlight appllication with disabled _sl_historyFrame无法将参数传递给已禁用 _sl_history 框架的 silverlight 应用程序
【发布时间】:2013-07-29 08:42:46
【问题描述】:
【问题讨论】:
标签:
c#
silverlight
navigation
【解决方案1】:
我通过将initParams 参数传递给aspx 页面中的silverlight 对象解决了这个问题。
页面.aspx
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2">
<param name="splashscreensource" value="SplashScreen.xaml" />
<%
string value = String.Empty;
// take parameters from QueryString
foreach (string key in Request.QueryString.Keys)
{
value += String.Format("{0}={1},", key, Request.QueryString.Get(key));
}
Response.Write(String.Format("<param name=\"initParams\" value=\"{0}\"/>", value));
// it writes <param name="initParams" value="id=1,var1=2,var2=3"
%>
<%-- another parameters --%>
</object>
在ApplicationStartup 方法中我这样处理
private void ApplicationStartup(object sender, StartupEventArgs e)
{
// some code...
if (e.InitParams != null)
{
// process our parameters
// example of getting: e.InitParams["ID"]
}
}
一些链接: