加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – PostBackUrl没有将Page.IsCrossPagePostBack设置为tr

发布时间:2020-12-16 10:00:52 所属栏目:asp.Net 来源:网络整理
导读:我手上有一个遗留应用程序,它使用ASP.NET WebForms. 我的问题是,LinkBut??ton控件没有将Page.IsCrossPagePostBack设置为true.在此应用程序中,有6个LinkBut??ton控件用于创建相关实体(它们回发到与表单元素的操作不同的页面).这MSDN Article声称PostBackUrl导
我手上有一个遗留应用程序,它使用ASP.NET WebForms.

我的问题是,LinkBut??ton控件没有将Page.IsCrossPagePostBack设置为true.在此应用程序中,有6个LinkBut??ton控件用于创建相关实体(它们回发到与表单元素的操作不同的页面).这MSDN Article声称PostBackUrl导致Page.IsCrossPagePostBack变为true.但在我的代码中,情况并非如此.它总是返回false.

任何的想法?

解决方法

这有点违反直觉,但你必须仔细阅读:

In either case,the PreviousPage page property will contain an object that represents the previous or originator page. If,for example,Page A posts to Page B,Page A’s IsCrossPagePostBack property (accessible through the PreviousPage property) will be true and Page B’s PreviousPage property will have the name of Page A.

所以解决方案是:

if (PreviousPage != null && PreviousPage.IsCrossPagePostBack)
        // do stuff

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读