【问题标题】:Is there an analog to "locate.replace()" in Silverlight 4 Navigation?Silverlight 4 Navigation 中是否有“locate.replace()”的类似物?
【发布时间】:2010-10-30 03:58:32
【问题描述】:

如果用户导航到显示“添加项目”视图 (#/items/add) 的页面,我希望在他们保存项目后单击“返回”时基本上跳过该 URL。

我该怎么做?

这是我更详细的行为...如果用户已导航到并且当前在此 silverlight url:

#/items/list

当他们点击“添加”按钮时......他们被导航到

#/items/add

保存后,导航到

#/items/99(其中 99 是新的项目 ID。)

当他们从这里点击后退按钮时,我希望他们回到

#/items/list

【问题讨论】:

  • 我想如果一切都失败了,我可以使用 javascript 来做 locate.replace,对吧?
  • 我也对 Silverlight 导航感兴趣。我不能给出权威的答案,但我正在阅读这个silverlightshow.net/items/…

标签: c# .net silverlight silverlight-4.0 navigation


【解决方案1】:

我能够通过处理 Frame 的 Navigating 事件并在处理程序的主体中执行类似的操作来跳过特定的 url:

if (SomehowDecideToSkipThisOne(e))
{
    e.Cancel = true;
    Frame.StopLoading();
    Frame.Navigate(uriToRedirectTo);
}

但是,问题在于如何实现 SomehowDecideToSkipThisOne 因为根据 MSDN,"Any navigation request that the user initiates through a Web browser (including using the back or forward button of the Web browser) is represented as a New type of navigation."

因此,当用户单击浏览器上的后退按钮时,我不知道他们何时真正“返回”。所以,现在我想我会决定跳过这个功能的使用,特别是因为我不需要它来进行 SEO。我只是认为这对我的 Intranet 应用程序来说是一个很好的增强。但是在这种情况下很难正确支持。

【讨论】:

  • 实际上,我仍然可以使用导航,但我不会用它来导航到“添加项目”屏幕。
  • 答案基本上是“不”。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多