2013-07-29 83 views
0

我禁用了_sl_historyFrameaspx頁面以阻止後退/前進導航。現在我發現我不能傳遞參數給應用程序是這樣的:http://contoso.com:7553/Page.aspx#/Sub/1/2無法通過禁用_sl_historyFrame將參數傳遞給silverlight應用程序

我得到NavigationFrame_OnNavigating法空網址。

有什麼方法可以解決它嗎?

+0

有一些解決方法可以防止後退/前進導航http://mrpanot.wordpress.com/2010/05/19/prevent-browser-back-button-for-silverlight-with-confirm-dialog/,但它是desireable不改變現有的代碼。 – Nurlan

回答

0

我通過傳遞initParams參數到Silverlight的對象aspx頁面解決了這個問題。

Page.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"] 
    } 
} 

一些鏈接:

相關問題