【问题标题】:Can not pass parameters to silverlight appllication with disabled _sl_historyFrame无法将参数传递给已禁用 _sl_history 框架的 silverlight 应用程序
【发布时间】:2013-07-29 08:42:46
【问题描述】:

我在aspx 页面中禁用了_sl_historyFrame 以防止后退/前进导航。现在我发现我不能像这样将参数传递给应用程序:http://contoso.com:7553/Page.aspx#/Sub/1/2

我在 NavigationFrame_OnNavigating 方法上得到空 URL。

有什么办法可以解决吗?

【问题讨论】:

标签: 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"]
     }
}

一些链接:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-16
    • 2015-02-12
    • 2012-12-24
    • 2021-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多